mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-29 00:44:34 +02:00
fix(images): reconcile the image inventory with filesystem changes
This commit is contained in:
1 parent
efd6bb77fe
commit
046dff4d08
22 files changed
+1809
-335
No files matched your search
+27
-6
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import asyncio
|
||||
import pytest_asyncio
|
||||
import tempfile
|
||||
import shutil
|
||||
@@ -100,12 +101,32 @@ async def base_client(app: FastAPI, db_session: AsyncSession) -> AsyncGenerator[
|
||||
|
||||
app.dependency_overrides[get_db_session] = _get_test_db
|
||||
|
||||
async with AsyncClient(
|
||||
base_url="http://test-api",
|
||||
headers={"Content-Type": "application/json"},
|
||||
transport=ASGIWebSocketTransport(app=app)
|
||||
) as async_client:
|
||||
yield async_client
|
||||
# AnyIO cancel scopes must be entered and exited by the same task. Recent
|
||||
# pytest-asyncio versions finalize yield fixtures in a different task.
|
||||
ready = asyncio.get_running_loop().create_future()
|
||||
finished = asyncio.Event()
|
||||
|
||||
async def own_client():
|
||||
try:
|
||||
async with AsyncClient(
|
||||
base_url="http://test-api",
|
||||
headers={"Content-Type": "application/json"},
|
||||
transport=ASGIWebSocketTransport(app=app)
|
||||
) as async_client:
|
||||
ready.set_result(async_client)
|
||||
await finished.wait()
|
||||
except BaseException as e:
|
||||
if not ready.done():
|
||||
ready.set_exception(e)
|
||||
raise
|
||||
|
||||
owner = asyncio.create_task(own_client())
|
||||
try:
|
||||
yield await ready
|
||||
finally:
|
||||
finished.set()
|
||||
await owner
|
||||
app.dependency_overrides.pop(get_db_session, None)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(loop_scope="class", scope="class")
|
||||
|
||||
Reference in new issue
Block a user