MCPcopy
hub / github.com/python/mypy / use_tmp_dir

Function use_tmp_dir

mypy/test/teststubtest.py:28–42  ·  view source on GitHub ↗
(mod_name: str)

Source from the content-addressed store, hash-verified

26
27@contextlib.contextmanager
28def use_tmp_dir(mod_name: str) -> Iterator[str]:
29 current = os.getcwd()
30 current_syspath = sys.path.copy()
31 with tempfile.TemporaryDirectory() as tmp:
32 try:
33 os.chdir(tmp)
34 if sys.path[0] != tmp:
35 sys.path.insert(0, tmp)
36 yield tmp
37 finally:
38 sys.path = current_syspath.copy()
39 if mod_name in sys.modules:
40 del sys.modules[mod_name]
41
42 os.chdir(current)
43
44
45TEST_MODULE_NAME = "test_module"

Callers 3

run_stubtest_with_stderrFunction · 0.85
test_only_pyMethod · 0.85

Calls 2

insertMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…