[Python-checkins] cpython: Issue #15767: Add an explicit test for raising ModuleNotFoundError

brett.cannon python-checkins at python.org
Thu Jun 13 05:38:58 CEST 2013


http://hg.python.org/cpython/rev/c6c0faaf65d7
changeset: 84110:c6c0faaf65d7
user: Brett Cannon <brett at python.org>
date: Wed Jun 12 23:38:50 2013 -0400
summary:
 Issue #15767: Add an explicit test for raising ModuleNotFoundError
when None in sys.modules.
files:
 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
--- a/Lib/test/test_importlib/import_/test_api.py
+++ b/Lib/test/test_importlib/import_/test_api.py
@@ -26,6 +26,13 @@
 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):
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /