Inaccessible lock files now imply temporary directories can't be removed
Fix #7500 Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
@@ -358,17 +358,25 @@ def test_get_extended_length_path_str():
|
||||
|
||||
|
||||
def test_suppress_error_removing_lock(tmp_path):
|
||||
"""ensure_deletable should not raise an exception if the lock file cannot be removed (#5456)"""
|
||||
"""ensure_deletable should be resilient if lock file cannot be removed (#5456, #7491)"""
|
||||
path = tmp_path / "dir"
|
||||
path.mkdir()
|
||||
lock = get_lock_path(path)
|
||||
lock.touch()
|
||||
mtime = lock.stat().st_mtime
|
||||
|
||||
with unittest.mock.patch.object(Path, "unlink", side_effect=OSError):
|
||||
with unittest.mock.patch.object(Path, "unlink", side_effect=OSError) as m:
|
||||
assert not ensure_deletable(
|
||||
path, consider_lock_dead_if_created_before=mtime + 30
|
||||
)
|
||||
assert m.call_count == 1
|
||||
assert lock.is_file()
|
||||
|
||||
with unittest.mock.patch.object(Path, "is_file", side_effect=OSError) as m:
|
||||
assert not ensure_deletable(
|
||||
path, consider_lock_dead_if_created_before=mtime + 30
|
||||
)
|
||||
assert m.call_count == 1
|
||||
assert lock.is_file()
|
||||
|
||||
# check now that we can remove the lock file in normal circumstances
|
||||
|
||||
Reference in New Issue
Block a user