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

Function test_coroutine_function

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

Source from the content-addressed store, hash-verified

162
163@pytest.mark.asyncio
164async def test_coroutine_function(tmp_path: Path) -> None:
165 acquired = released = False
166
167 class AioFileLock(BaseAsyncFileLock):
168 async def _acquire(self) -> None: # ty: ignore[invalid-method-override]
169 nonlocal acquired
170 acquired = True
171 self._context.lock_file_fd = 1
172
173 async def _release(self) -> None: # ty: ignore[invalid-method-override]
174 nonlocal released
175 released = True
176 self._context.lock_file_fd = None
177
178 lock = AioFileLock(str(tmp_path / "a"))
179 await lock.acquire()
180 assert acquired
181 assert not released
182 await lock.release()
183 assert acquired
184 assert released
185
186
187@pytest.mark.parametrize("lock_type", [AsyncFileLock, AsyncSoftFileLock])

Callers

nothing calls this directly

Calls 3

AioFileLockClass · 0.85
acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…