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

Class TestHook

Lib/test/test_doctest/test_doctest.py:3234–3252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3232 return None
3233
3234class TestHook:
3235
3236 def __init__(self, pathdir):
3237 self.sys_path = sys.path[:]
3238 self.meta_path = sys.meta_path[:]
3239 self.path_hooks = sys.path_hooks[:]
3240 sys.path.append(pathdir)
3241 sys.path_importer_cache.clear()
3242 self.modules_before = sys.modules.copy()
3243 self.importer = TestImporter()
3244 sys.meta_path.append(self.importer)
3245
3246 def remove(self):
3247 sys.path[:] = self.sys_path
3248 sys.meta_path[:] = self.meta_path
3249 sys.path_hooks[:] = self.path_hooks
3250 sys.path_importer_cache.clear()
3251 sys.modules.clear()
3252 sys.modules.update(self.modules_before)
3253
3254
3255@contextlib.contextmanager

Callers 1

test_hookFunction · 0.70

Calls

no outgoing calls

Tested by 1

test_hookFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…