(mod_name: str)
| 26 | |
| 27 | @contextlib.contextmanager |
| 28 | def 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 | |
| 45 | TEST_MODULE_NAME = "test_module" |
no test coverage detected
searching dependent graphs…