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

Function test_nested_context_manager

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

Source from the content-addressed store, hash-verified

140
141@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
142def test_nested_context_manager(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
143 # lock is not released before the most outer with statement that locked the lock, is left
144 lock_path = tmp_path / "a"
145 lock = lock_type(str(lock_path))
146
147 with lock as lock_1:
148 assert lock.is_locked
149 assert lock is lock_1
150
151 with lock as lock_2:
152 assert lock.is_locked
153 assert lock is lock_2
154
155 with lock as lock_3:
156 assert lock.is_locked
157 assert lock is lock_3
158
159 assert lock.is_locked
160 assert lock.is_locked
161 assert not lock.is_locked
162
163
164@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected