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

Function test_nested_context_managers

tests/sqlite/test_async.py:200–210  ·  view source on GitHub ↗
(lock_file: str, mode: Literal["read", "write"])

Source from the content-addressed store, hash-verified

198@pytest.mark.parametrize("mode", [pytest.param("read", id="read"), pytest.param("write", id="write")])
199@pytest.mark.asyncio
200async def test_nested_context_managers(lock_file: str, mode: Literal["read", "write"]) -> None:
201 lock = AsyncReadWriteLock(lock_file, is_singleton=False)
202 make_ctx = getattr(lock, f"{mode}_lock")
203 async with make_ctx():
204 assert_mode_held(lock_file, mode)
205 async with make_ctx():
206 assert_mode_held(lock_file, mode)
207 assert_mode_held(lock_file, mode)
208 with pytest.raises(RuntimeError, match="not held"):
209 await lock.release()
210 await lock.close()
211
212
213@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

AsyncReadWriteLockClass · 0.90
assert_mode_heldFunction · 0.90
releaseMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected