MCPcopy
hub / github.com/pytest-dev/pytest / _force_symlink

Function _force_symlink

src/_pytest/pathlib.py:204–221  ·  view source on GitHub ↗

Helper to create the current symlink. It's full of race conditions that are reasonably OK to ignore for the context of best effort linking to the latest test run. The presumption being that in case of much parallelism the inaccuracy is going to be acceptable.

(root: Path, target: str | PurePath, link_to: str | Path)

Source from the content-addressed store, hash-verified

202
203
204def _force_symlink(root: Path, target: str | PurePath, link_to: str | Path) -> None:
205 """Helper to create the current symlink.
206
207 It's full of race conditions that are reasonably OK to ignore
208 for the context of best effort linking to the latest test run.
209
210 The presumption being that in case of much parallelism
211 the inaccuracy is going to be acceptable.
212 """
213 current_symlink = root.joinpath(target)
214 try:
215 current_symlink.unlink()
216 except OSError:
217 pass
218 try:
219 current_symlink.symlink_to(link_to)
220 except Exception:
221 pass
222
223
224def make_numbered_dir(root: Path, prefix: str, mode: int = 0o700) -> Path:

Callers 1

make_numbered_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected