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

Function _force_symlink

src/_pytest/pathlib.py:187–206  ·  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: Union[str, PurePath], link_to: Union[str, Path]
)

Source from the content-addressed store, hash-verified

185
186
187def _force_symlink(
188 root: Path, target: Union[str, PurePath], link_to: Union[str, Path]
189) -> None:
190 """Helper to create the current symlink.
191
192 It's full of race conditions that are reasonably OK to ignore
193 for the context of best effort linking to the latest test run.
194
195 The presumption being that in case of much parallelism
196 the inaccuracy is going to be acceptable.
197 """
198 current_symlink = root.joinpath(target)
199 try:
200 current_symlink.unlink()
201 except OSError:
202 pass
203 try:
204 current_symlink.symlink_to(link_to)
205 except Exception:
206 pass
207
208
209def 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