diff --git a/tests/test_soft_lease.py b/tests/test_soft_lease.py index 44af7ec4..9aa7e53d 100644 --- a/tests/test_soft_lease.py +++ b/tests/test_soft_lease.py @@ -217,7 +217,8 @@ def flaky(path: str, *args: object, **kwargs: object) -> object: mocker.patch(f"filelock._lease.{target}", side_effect=flaky) seen: list[LeaseCompromise] = [] - lease = _lease(marker, on_compromise=seen.append) + # A long lease keeps a slow runner's two failed ticks inside the window; the deadline has its own test above. + lease = _lease(marker, lease_duration=30, on_compromise=seen.append) with lease: time.sleep(_HEARTBEAT * 6) # several ticks: the first two fail, the rest recover assert seen == [] diff --git a/tests/test_strict_soft_failures.py b/tests/test_strict_soft_failures.py index 008c19e7..3aa9949a 100644 --- a/tests/test_strict_soft_failures.py +++ b/tests/test_strict_soft_failures.py @@ -494,11 +494,11 @@ def test_strict_soft_reaper_does_not_retry_sharing_error(tmp_path: Path, mocker: side_effect=PermissionError(EACCES, "sharing violation"), ) - started = time.perf_counter() + sleep = mocker.patch("filelock._strict.time.sleep") + assert StrictSoftFileLock(lock_path).claims == () - elapsed = time.perf_counter() - started reaper_unlinks = [call.args[0] for call in unlink.call_args_list].count(private_path) - assert (reaper_unlinks, elapsed < 0.1, private_path.exists()) == (1, True, True) + assert (reaper_unlinks, sleep.call_count, private_path.exists()) == (1, 0, True) @pytest.mark.parametrize("record", ["claim", "sentinel"])