diff options
author | Brett Cannon <brett@python.org> | 2013-06-13 03:38:50 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-06-13 03:38:50 (GMT) |
commit | e5b25df16d10f6e3fb5010c29bfcc155f8b09bef (patch) | |
tree | 2f387f62adc5740912cea22b46d3ef99b5790241 /Lib/test/test_importlib | |
parent | 8f5ac5106eb24dd8bda91f25e993a90a820a2d5c (diff) | |
download | cpython-e5b25df16d10f6e3fb5010c29bfcc155f8b09bef.zip cpython-e5b25df16d10f6e3fb5010c29bfcc155f8b09bef.tar.gz cpython-e5b25df16d10f6e3fb5010c29bfcc155f8b09bef.tar.bz2 |
Issue #15767: Add an explicit test for raising ModuleNotFoundError
when None in sys.modules.
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r-- | Lib/test/test_importlib/import_/test_api.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/import_/test_api.py b/Lib/test/test_importlib/import_/test_api.py index 6aca6dc..4b7baad 100644 --- a/Lib/test/test_importlib/import_/test_api.py +++ b/Lib/test/test_importlib/import_/test_api.py @@ -26,6 +26,13 @@ class APITest(unittest.TestCase): with self.assertRaises(ModuleNotFoundError): util.import_('some module that does not exist') + def test_raises_ModuleNotFoundError_for_None(self): + # None in sys.modules should raise ModuleNotFoundError. + with importlib_test_util.uncache('not_here'): + sys.modules['not_here'] = None + with self.assertRaises(ModuleNotFoundError): + util.import_('not_here') + def test_name_requires_rparition(self): # Raise TypeError if a non-string is passed in for the module name. with self.assertRaises(TypeError): |