MCPcopy Index your code
hub / github.com/python/cpython / check_importmodulelevel

Method check_importmodulelevel

Lib/test/test_capi/test_import.py:187–201  ·  view source on GitHub ↗
(self, importmodulelevel)

Source from the content-addressed store, hash-verified

185 # CRASHES importmoduleex(NULL, NULL, NULL, NULL)
186
187 def check_importmodulelevel(self, importmodulelevel):
188 self.check_import_func(lambda name: importmodulelevel(name, NULL, NULL, NULL, 0))
189
190 self.assertRaises(ModuleNotFoundError, importmodulelevel, 'nonexistent', NULL, NULL, NULL, 0)
191 self.assertRaises(ValueError, importmodulelevel, '', NULL, NULL, NULL, 0)
192
193 if __package__:
194 self.assertIs(importmodulelevel('test_import', globals(), NULL, NULL, 1),
195 sys.modules['test.test_capi.test_import'])
196 self.assertIs(importmodulelevel('test_capi', globals(), NULL, NULL, 2),
197 sys.modules['test.test_capi'])
198 self.assertRaises(ValueError, importmodulelevel, 'os', NULL, NULL, NULL, -1)
199 with self.assertWarns(ImportWarning):
200 self.assertRaises(KeyError, importmodulelevel, 'test_import', {}, NULL, NULL, 1)
201 self.assertRaises(TypeError, importmodulelevel, 'test_import', [], NULL, NULL, 1)
202
203 def test_importmodulelevel(self):
204 # Test PyImport_ImportModuleLevel()

Callers 2

Calls 4

check_import_funcMethod · 0.95
assertWarnsMethod · 0.80
assertRaisesMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected