Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5b25df

Browse files
committed
Issue #15767: Add an explicit test for raising ModuleNotFoundError
when None in sys.modules.
1 parent 8f5ac51 commit e5b25df

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_importlib/import_/test_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ def test_raises_ModuleNotFoundError(self):
2626
with self.assertRaises(ModuleNotFoundError):
2727
util.import_('some module that does not exist')
2828

29+
def test_raises_ModuleNotFoundError_for_None(self):
30+
# None in sys.modules should raise ModuleNotFoundError.
31+
with importlib_test_util.uncache('not_here'):
32+
sys.modules['not_here'] = None
33+
with self.assertRaises(ModuleNotFoundError):
34+
util.import_('not_here')
35+
2936
def test_name_requires_rparition(self):
3037
# Raise TypeError if a non-string is passed in for the module name.
3138
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)