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

Function cleanup_candidates

src/_pytest/pathlib.py:341–350  ·  view source on GitHub ↗

List candidates for numbered directories to be removed - follows py.path.

(root: Path, prefix: str, keep: int)

Source from the content-addressed store, hash-verified

339
340
341def cleanup_candidates(root: Path, prefix: str, keep: int) -> Iterator[Path]:
342 """List candidates for numbered directories to be removed - follows py.path."""
343 max_existing = max(map(parse_num, find_suffixes(root, prefix)), default=-1)
344 max_delete = max_existing - keep
345 entries = find_prefixed(root, prefix)
346 entries, entries2 = itertools.tee(entries)
347 numbers = map(parse_num, extract_suffixes(entries2, prefix))
348 for entry, number in zip(entries, numbers, strict=True):
349 if number <= max_delete:
350 yield Path(entry)
351
352
353def cleanup_dead_symlinks(root: Path) -> None:

Callers 1

cleanup_numbered_dirFunction · 0.85

Calls 3

find_suffixesFunction · 0.85
find_prefixedFunction · 0.85
extract_suffixesFunction · 0.85

Tested by

no test coverage detected