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

Class TestingImporter

Lib/test/test_importlib/test_lazy.py:41–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41class TestingImporter(abc.MetaPathFinder, abc.Loader):
42
43 module_name = 'lazy_loader_test'
44 mutated_name = 'changed'
45 loaded = None
46 load_count = 0
47 source_code = 'attr = 42; __name__ = {!r}'.format(mutated_name)
48
49 def find_spec(self, name, path, target=None):
50 if name != self.module_name:
51 return None
52 return util.spec_from_loader(name, util.LazyLoader(self))
53
54 def exec_module(self, module):
55 time.sleep(0.01) # Simulate a slow load.
56 exec(self.source_code, module.__dict__)
57 self.loaded = module
58 self.load_count += 1
59
60
61class LazyLoaderTests(unittest.TestCase):

Callers 3

new_moduleMethod · 0.85
test_e2eMethod · 0.85
test_module_load_raceMethod · 0.85

Calls 1

formatMethod · 0.45

Tested by 3

new_moduleMethod · 0.68
test_e2eMethod · 0.68
test_module_load_raceMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…