diff --git a/examples/fastapi/_tests.py b/examples/fastapi/_tests.py index 720f56791..dab3462cc 100644 --- a/examples/fastapi/_tests.py +++ b/examples/fastapi/_tests.py @@ -2,7 +2,7 @@ # pylint: disable=E0611,E0401 import pytest from asgi_lifespan import LifespanManager -from httpx import AsyncClient +from httpx import ASGITransport, AsyncClient from main import app from models import Users @@ -15,7 +15,8 @@ def anyio_backend(): @pytest.fixture(scope="module") async def client(): async with LifespanManager(app): - async with AsyncClient(app=app, base_url="http://test") as c: + transport = ASGITransport(app=app) + async with AsyncClient(transport=transport, base_url="http://test") as c: yield c diff --git a/examples/fastapi/main.py b/examples/fastapi/main.py index a7744579f..db36c3a62 100644 --- a/examples/fastapi/main.py +++ b/examples/fastapi/main.py @@ -2,10 +2,9 @@ from contextlib import asynccontextmanager from typing import List -from fastapi import FastAPI +from fastapi import FastAPI, HTTPException from models import User_Pydantic, UserIn_Pydantic, Users from pydantic import BaseModel -from starlette.exceptions import HTTPException from tortoise.contrib.fastapi import RegisterTortoise