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

Function test_default_timeout

tests/core/test_timeout.py:74–98  ·  view source on GitHub ↗
(lock_type: type[BaseFileLock], tmp_path: Path)

Source from the content-addressed store, hash-verified

72
73@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
74def test_default_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
75 lock_path = tmp_path / "a"
76 lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path), timeout=0.1)
77 assert lock_2.timeout == pytest.approx(0.1)
78
79 lock_1.acquire()
80 assert lock_1.is_locked
81 assert not lock_2.is_locked
82
83 with pytest.raises(Timeout, match=r"The file lock '.*' could not be acquired."):
84 lock_2.acquire()
85 assert not lock_2.is_locked
86 assert lock_1.is_locked
87
88 lock_2.timeout = 0
89 assert lock_2.timeout == 0
90
91 with pytest.raises(Timeout, match=r"The file lock '.*' could not be acquired."):
92 lock_2.acquire()
93 assert not lock_2.is_locked
94 assert lock_1.is_locked
95
96 lock_1.release()
97 assert not lock_1.is_locked
98 assert not lock_2.is_locked
99
100
101@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])

Callers

nothing calls this directly

Calls 3

lock_typeFunction · 0.85
acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected