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

Function test_suppress_error_removing_lock

testing/test_pathlib.py:496–520  ·  view source on GitHub ↗

ensure_deletable should be resilient if lock file cannot be removed (#5456, #7491)

(tmp_path: Path)

Source from the content-addressed store, hash-verified

494
495
496def test_suppress_error_removing_lock(tmp_path: Path) -> None:
497 """ensure_deletable should be resilient if lock file cannot be removed (#5456, #7491)"""
498 path = tmp_path / "dir"
499 path.mkdir()
500 lock = get_lock_path(path)
501 lock.touch()
502 mtime = lock.stat().st_mtime
503
504 with unittest.mock.patch.object(Path, "unlink", side_effect=OSError) as m:
505 assert not ensure_deletable(
506 path, consider_lock_dead_if_created_before=mtime + 30
507 )
508 assert m.call_count == 1
509 assert lock.is_file()
510
511 with unittest.mock.patch.object(Path, "is_file", side_effect=OSError) as m:
512 assert not ensure_deletable(
513 path, consider_lock_dead_if_created_before=mtime + 30
514 )
515 assert m.call_count == 1
516 assert lock.is_file()
517
518 # check now that we can remove the lock file in normal circumstances
519 assert ensure_deletable(path, consider_lock_dead_if_created_before=mtime + 30)
520 assert not lock.is_file()
521
522
523def test_bestrelpath() -> None:

Callers

nothing calls this directly

Calls 4

get_lock_pathFunction · 0.90
ensure_deletableFunction · 0.90
statMethod · 0.80
mkdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…