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

Function test_nested_context_managers

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

Source from the content-addressed store, hash-verified

244@pytest.mark.parametrize("mode", [pytest.param("read", id="read"), pytest.param("write", id="write")])
245@pytest.mark.asyncio
246async def test_nested_context_managers(lock_file: str, mode: Literal["read", "write"]) -> None:
247 lock = AsyncReadWriteLock(lock_file, is_singleton=False)
248 make_ctx = lock.read_lock if mode == "read" else lock.write_lock
249 async with make_ctx():
250 assert_mode_held(lock_file, mode)
251 async with make_ctx():
252 assert_mode_held(lock_file, mode)
253 assert_mode_held(lock_file, mode)
254 with pytest.raises(RuntimeError, match="not held"):
255 await lock.release()
256 await lock.close()
257
258
259@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected