(self)
| 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 |
nothing calls this directly
no test coverage detected