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

Function test_coroutine_function

tests/test_async_filelock.py:161–181  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

159
160@pytest.mark.asyncio
161async def test_coroutine_function(tmp_path: Path) -> None:
162 acquired = released = False
163
164 class AioFileLock(BaseAsyncFileLock):
165 async def _acquire(self) -> None: # type: ignore[override]
166 nonlocal acquired
167 acquired = True
168 self._context.lock_file_fd = 1
169
170 async def _release(self) -> None: # type: ignore[override]
171 nonlocal released
172 released = True
173 self._context.lock_file_fd = None
174
175 lock = AioFileLock(str(tmp_path / "a"))
176 await lock.acquire()
177 assert acquired
178 assert not released
179 await lock.release()
180 assert acquired
181 assert released

Callers

nothing calls this directly

Calls 3

AioFileLockClass · 0.85
acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected