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

View File

@ -1,14 +1,17 @@
from unittest import mock from unittest import mock
import pytest import pytest
from httpx import AsyncClient from httpx import ASGITransport, AsyncClient
from fastapi_di_example import app, container, Service from fastapi_di_example import app, container, Service
@pytest.fixture @pytest.fixture
async def client(event_loop): 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 yield client

View File

@ -3,7 +3,7 @@
from unittest import mock from unittest import mock
import pytest import pytest
from httpx import AsyncClient from httpx import ASGITransport, AsyncClient
from giphynavigator.application import app from giphynavigator.application import app
from giphynavigator.giphy import GiphyClient from giphynavigator.giphy import GiphyClient
@ -11,7 +11,10 @@ from giphynavigator.giphy import GiphyClient
@pytest.fixture @pytest.fixture
async def client(): 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 yield client

View File

@ -1,4 +1,4 @@
from httpx import AsyncClient from httpx import ASGITransport, AsyncClient
from pytest import fixture, mark from pytest import fixture, mark
from pytest_asyncio import fixture as aio_fixture from pytest_asyncio import fixture as aio_fixture
@ -19,7 +19,7 @@ from wiringfastapi import web
@aio_fixture @aio_fixture
async def async_client(): 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 yield client
await client.aclose() await client.aclose()