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

Function test_suppress_error_removing_lock

testing/test_pathlib.py:496–520  ·  testing/test_pathlib.py::test_suppress_error_removing_lock

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 class="st">""class="st">"ensure_deletable should be resilient if lock file cannot be removed (class="cm">#5456, #7491)"class="st">""
498 path = tmp_path / class="st">"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, class="st">"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, class="st">"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 class="cm"># 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