bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528) · python/cpython@bfa89b2 (original) (raw)
1
1
`""" Test suite for the code in msilib """
`
``
2
`+
import os.path
`
2
3
`import unittest
`
3
4
`from test.support import TESTFN, import_module, unlink
`
4
5
`msilib = import_module('msilib')
`
`@@ -40,6 +41,17 @@ def test_view_fetch_returns_none(self):
`
40
41
` )
`
41
42
`self.addCleanup(unlink, db_path)
`
42
43
``
``
44
`+
def test_database_open_failed(self):
`
``
45
`+
with self.assertRaises(msilib.MSIError) as cm:
`
``
46
`+
msilib.OpenDatabase('non-existent.msi', msilib.MSIDBOPEN_READONLY)
`
``
47
`+
self.assertEqual(str(cm.exception), 'open failed')
`
``
48
+
``
49
`+
def test_database_create_failed(self):
`
``
50
`+
db_path = os.path.join(TESTFN, 'test.msi')
`
``
51
`+
with self.assertRaises(msilib.MSIError) as cm:
`
``
52
`+
msilib.OpenDatabase(db_path, msilib.MSIDBOPEN_CREATE)
`
``
53
`+
self.assertEqual(str(cm.exception), 'create failed')
`
``
54
+
43
55
``
44
56
`class Test_make_id(unittest.TestCase):
`
45
57
`#http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx
`