From 85789ee4adc7250a5916643533406b0b43ae98dd Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 24 Mar 2024 18:34:11 +0100 Subject: [PATCH] refactor: httpx transport warning fixed --- db/create.sql | 2 ++ tests/conftest.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/db/create.sql b/db/create.sql index 35d64d4..6df30d2 100644 --- a/db/create.sql +++ b/db/create.sql @@ -1,3 +1,5 @@ +-- DROP DATABASE IF EXISTS devdb; +-- CREATE DATABASE devdb; \connect devdb; CREATE SCHEMA shakespeare; CREATE SCHEMA happy_hog; diff --git a/tests/conftest.py b/tests/conftest.py index 97e6f0e..88b5ff6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ import pytest -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from app.database import engine from app.main import app @@ -29,10 +29,16 @@ async def start_db(): @pytest.fixture(scope="session") async def client(start_db) -> AsyncClient: - async with AsyncClient( + + transport = ASGITransport( app=app, + + ) + async with AsyncClient( + # app=app, base_url="http://testserver/v1", headers={"Content-Type": "application/json"}, + transport=transport, ) as test_client: app.state.redis = await get_redis() yield test_client