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

Function test_lock_context_manager

tests/test_async_read_write.py:51–58  ·  view source on GitHub ↗
(lock_file: str, mode: Literal["read", "write"])

Source from the content-addressed store, hash-verified

49@pytest.mark.parametrize("mode", [pytest.param("read", id="read"), pytest.param("write", id="write")])
50@pytest.mark.asyncio
51async def test_lock_context_manager(lock_file: str, mode: Literal["read", "write"]) -> None:
52 lock = AsyncReadWriteLock(lock_file, is_singleton=False)
53 ctx = lock.read_lock() if mode == "read" else lock.write_lock()
54 async with ctx:
55 assert_mode_held(lock_file, mode)
56 with pytest.raises(RuntimeError, match="not held"):
57 await lock.release()
58 await lock.close()
59
60
61@pytest.mark.parametrize("mode", [pytest.param("read", id="read"), pytest.param("write", id="write")])

Callers

nothing calls this directly

Calls 6

read_lockMethod · 0.95
write_lockMethod · 0.95
releaseMethod · 0.95
closeMethod · 0.95
AsyncReadWriteLockClass · 0.90
assert_mode_heldFunction · 0.85

Tested by

no test coverage detected