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

Method test_getmodule

Lib/test/test_capi/test_import.py:55–67  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53 sys.modules.update(old_modules)
54
55 def test_getmodule(self):
56 # Test PyImport_GetModule()
57 getmodule = _testlimitedcapi.PyImport_GetModule
58 self.check_import_loaded_module(getmodule)
59
60 nonexistent = 'nonexistent'
61 self.assertNotIn(nonexistent, sys.modules)
62 self.assertIs(getmodule(nonexistent), KeyError)
63 self.assertIs(getmodule(''), KeyError)
64 self.assertIs(getmodule(object()), KeyError)
65
66 self.assertRaises(TypeError, getmodule, []) # unhashable
67 # CRASHES getmodule(NULL)
68
69 def check_addmodule(self, add_module, accept_nonstr=False):
70 # create a new module

Callers

nothing calls this directly

Calls 5

assertNotInMethod · 0.80
getmoduleFunction · 0.50
assertIsMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected