fix: use ASGITransport for httpx AsyncClient in tests
- httpx.AsyncClient requires ASGITransport for FastAPI app testing - Updated all test files to use correct API
This commit is contained in:
@@ -3,7 +3,7 @@ import pytest_asyncio
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
|
||||
from app.database import Base, get_db
|
||||
from app.main import app
|
||||
from httpx import AsyncClient
|
||||
from httpx import AsyncClient, ASGITransport
|
||||
|
||||
TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
|
||||
|
||||
@@ -28,6 +28,6 @@ async def client(db):
|
||||
yield db
|
||||
|
||||
app.dependency_overrides[get_db] = override_get_db
|
||||
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac:
|
||||
yield ac
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
Reference in New Issue
Block a user