refactor: httpx transport warning fixed

This commit is contained in:
Jakub Miazek 2024-03-24 18:34:11 +01:00
parent 7e34800d78
commit 85789ee4ad
2 changed files with 10 additions and 2 deletions

View File

@ -1,3 +1,5 @@
-- DROP DATABASE IF EXISTS devdb;
-- CREATE DATABASE devdb;
\connect devdb; \connect devdb;
CREATE SCHEMA shakespeare; CREATE SCHEMA shakespeare;
CREATE SCHEMA happy_hog; CREATE SCHEMA happy_hog;

View File

@ -1,5 +1,5 @@
import pytest import pytest
from httpx import AsyncClient from httpx import AsyncClient, ASGITransport
from app.database import engine from app.database import engine
from app.main import app from app.main import app
@ -29,10 +29,16 @@ async def start_db():
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
async def client(start_db) -> AsyncClient: async def client(start_db) -> AsyncClient:
async with AsyncClient(
transport = ASGITransport(
app=app, app=app,
)
async with AsyncClient(
# app=app,
base_url="http://testserver/v1", base_url="http://testserver/v1",
headers={"Content-Type": "application/json"}, headers={"Content-Type": "application/json"},
transport=transport,
) as test_client: ) as test_client:
app.state.redis = await get_redis() app.state.redis = await get_redis()
yield test_client yield test_client