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

Function test_default_timeout

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

Source from the content-addressed store, hash-verified

397
398@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
399def test_default_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
400 # test if the default timeout parameter works
401 lock_path = tmp_path / "a"
402 lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path), timeout=0.1)
403 assert lock_2.timeout == pytest.approx(0.1)
404
405 # acquire lock 1
406 lock_1.acquire()
407 assert lock_1.is_locked
408 assert not lock_2.is_locked
409
410 # try to acquire lock 2
411 with pytest.raises(Timeout, match=r"The file lock '.*' could not be acquired."):
412 lock_2.acquire()
413 assert not lock_2.is_locked
414 assert lock_1.is_locked
415
416 lock_2.timeout = 0
417 assert lock_2.timeout == 0
418
419 with pytest.raises(Timeout, match=r"The file lock '.*' could not be acquired."):
420 lock_2.acquire()
421 assert not lock_2.is_locked
422 assert lock_1.is_locked
423
424 # release lock 1
425 lock_1.release()
426 assert not lock_1.is_locked
427 assert not lock_2.is_locked
428
429
430@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…