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

Function test_coroutine_function

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

Source from the content-addressed store, hash-verified

177
178@pytest.mark.asyncio
179async def test_coroutine_function(tmp_path: Path) -> None:
180 acquired = released = False
181
182 class AioFileLock(BaseAsyncFileLock):
183 async def _acquire(self) -> None: # ty: ignore[invalid-method-override]
184 nonlocal acquired
185 acquired = True
186 self._context.lock_file_fd = 1
187
188 async def _release(self) -> None: # ty: ignore[invalid-method-override]
189 nonlocal released
190 released = True
191 self._context.lock_file_fd = None
192
193 lock = AioFileLock(str(tmp_path / "a"))
194 await lock.acquire()
195 assert acquired
196 assert not released
197 await lock.release()
198 assert acquired
199 assert released
200
201
202@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 3

AioFileLockClass · 0.85
acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected