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

Function test_timeout

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

Source from the content-addressed store, hash-verified

305
306@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
307def test_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
308 # raises Timeout error when the lock cannot be acquired
309 lock_path = tmp_path / "a"
310 lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path))
311
312 # acquire lock 1
313 lock_1.acquire()
314 assert lock_1.is_locked
315 assert not lock_2.is_locked
316
317 # try to acquire lock 2
318 with pytest.raises(Timeout, match=r"The file lock '.*' could not be acquired."):
319 lock_2.acquire(timeout=0.1)
320 assert not lock_2.is_locked
321 assert lock_1.is_locked
322
323 # release lock 1
324 lock_1.release()
325 assert not lock_1.is_locked
326 assert not lock_2.is_locked
327
328
329@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

Used in the wild real call sites across dependent graphs

searching dependent graphs…