MCPcopy Create free account
hub / github.com/tox-dev/filelock / test_timeout

Function test_timeout

tests/test_filelock.py:296–315  ·  view source on GitHub ↗
(lock_type: type[BaseFileLock], tmp_path: Path)

Source from the content-addressed store, hash-verified

294
295@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
296def test_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
297 # raises Timeout error when the lock cannot be acquired
298 lock_path = tmp_path / "a"
299 lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path))
300
301 # acquire lock 1
302 lock_1.acquire()
303 assert lock_1.is_locked
304 assert not lock_2.is_locked
305
306 # try to acquire lock 2
307 with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."):
308 lock_2.acquire(timeout=0.1)
309 assert not lock_2.is_locked
310 assert lock_1.is_locked
311
312 # release lock 1
313 lock_1.release()
314 assert not lock_1.is_locked
315 assert not lock_2.is_locked
316
317
318@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])

Callers

nothing calls this directly

Calls 2

acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected