MCPcopy Create free account
hub / github.com/pytest-dev/pytest / subst_path_windows

Function subst_path_windows

testing/test_link_resolve.py:13–33  ·  view source on GitHub ↗
(filepath: Path)

Source from the content-addressed store, hash-verified

11
12@contextmanager
13def subst_path_windows(filepath: Path):
14 for c in ascii_lowercase[7:]: # Create a subst drive from H-Z.
15 c += ":"
16 if not os.path.exists(c):
17 drive = c
18 break
19 else:
20 raise AssertionError("Unable to find suitable drive letter for subst.")
21
22 directory = filepath.parent
23 basename = filepath.name
24
25 args = ["subst", drive, str(directory)]
26 subprocess.check_call(args)
27 assert os.path.exists(drive)
28 try:
29 filename = Path(drive, os.sep, basename)
30 yield filename
31 finally:
32 args = ["subst", "/D", drive]
33 subprocess.check_call(args)
34
35
36@contextmanager

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected