diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-24 10:31:21 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2017-11-24 10:31:21 (GMT) |
commit | bfa89b21e119bac7fed4a5decc26f1fff8ec359e (patch) | |
tree | 60358ab68ad7611fc5e44d94270e7cdb6eee378a /Lib | |
parent | 90abbee7aa8a254fba2d8fdebc574cb8426899dc (diff) | |
download | cpython-bfa89b21e119bac7fed4a5decc26f1fff8ec359e.zip cpython-bfa89b21e119bac7fed4a5decc26f1fff8ec359e.tar.gz cpython-bfa89b21e119bac7fed4a5decc26f1fff8ec359e.tar.bz2 |
bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
Previously, 'msilib.OpenDatabase()' function raised a
cryptical exception message when it couldn't open or
create an MSI file. For example:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_msi.MSIError: unknown error 6e
(cherry picked from commit 4864a619dc1cc9092780ccf5a6327e8abf66133d)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_msilib.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_msilib.py b/Lib/test/test_msilib.py index aa19883..eb2c76e 100644 --- a/Lib/test/test_msilib.py +++ b/Lib/test/test_msilib.py @@ -1,4 +1,5 @@ """ Test suite for the code in msilib """ +import os.path import unittest from test.support import TESTFN, import_module, unlink msilib = import_module('msilib') @@ -40,6 +41,17 @@ class MsiDatabaseTestCase(unittest.TestCase): ) self.addCleanup(unlink, db_path) + def test_database_open_failed(self): + with self.assertRaises(msilib.MSIError) as cm: + msilib.OpenDatabase('non-existent.msi', msilib.MSIDBOPEN_READONLY) + self.assertEqual(str(cm.exception), 'open failed') + + def test_database_create_failed(self): + db_path = os.path.join(TESTFN, 'test.msi') + with self.assertRaises(msilib.MSIError) as cm: + msilib.OpenDatabase(db_path, msilib.MSIDBOPEN_CREATE) + self.assertEqual(str(cm.exception), 'create failed') + class Test_make_id(unittest.TestCase): #http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx |