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

Method test_module_replaced

Lib/test/test_importlib/test_api.py:188–202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

186 self.init.reload(module)
187
188 def test_module_replaced(self):
189 def code():
190 import sys
191 module = type(sys)('top_level')
192 module.spam = 3
193 sys.modules['top_level'] = module
194 mock = test_util.mock_spec('top_level',
195 module_code={'top_level': code})
196 with mock:
197 with test_util.import_state(meta_path=[mock]):
198 module = self.init.import_module('top_level')
199 reloaded = self.init.reload(module)
200 actual = sys.modules['top_level']
201 self.assertEqual(actual.spam, 3)
202 self.assertEqual(reloaded.spam, 3)
203
204 def test_reload_missing_loader(self):
205 with import_helper.CleanImport('types'):

Callers

nothing calls this directly

Calls 3

import_moduleMethod · 0.45
reloadMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected