Fix compatibility with httpx v0.27.0

This commit is contained in:
ZipFile 2024-11-30 15:12:47 +00:00
parent 160b089875
commit 8cec99dc35
4 changed files with 17 additions and 8 deletions

View File

@ -3,7 +3,7 @@
from unittest import mock
import pytest
from httpx import AsyncClient
from httpx import ASGITransport, AsyncClient
from .application import app, container
from .services import Service
@ -11,7 +11,10 @@ from .services import Service
@pytest.fixture
def client(event_loop):
client = AsyncClient(app=app, base_url="http://test")
client = AsyncClient(
transport=ASGITransport(app=app),
base_url="http://test",
)
yield client
event_loop.run_until_complete(client.aclose())

View File

@ -1,14 +1,17 @@
from unittest import mock
import pytest
from httpx import AsyncClient
from httpx import ASGITransport, AsyncClient
from fastapi_di_example import app, container, Service
@pytest.fixture
async def client(event_loop):
async with AsyncClient(app=app, base_url="http://test") as client:
async with AsyncClient(
transport=ASGITransport(app=app),
base_url="http://test",
) as client:
yield client

View File

@ -3,7 +3,7 @@
from unittest import mock
import pytest
from httpx import AsyncClient
from httpx import ASGITransport, AsyncClient
from giphynavigator.application import app
from giphynavigator.giphy import GiphyClient
@ -11,7 +11,10 @@ from giphynavigator.giphy import GiphyClient
@pytest.fixture
async def client():
async with AsyncClient(app=app, base_url="http://test") as client:
async with AsyncClient(
transport=ASGITransport(app=app),
base_url="http://test",
) as client:
yield client

View File

@ -1,4 +1,4 @@
from httpx import AsyncClient
from httpx import ASGITransport, AsyncClient
from pytest import fixture, mark
from pytest_asyncio import fixture as aio_fixture
@ -19,7 +19,7 @@ from wiringfastapi import web
@aio_fixture
async def async_client():
client = AsyncClient(app=web.app, base_url="http://test")
client = AsyncClient(transport=ASGITransport(app=web.app), base_url="http://test")
yield client
await client.aclose()