Skip to content

Commit

Permalink
Update fastapi example to avoid warning: `The "app" shortcut is now d…
Browse files Browse the repository at this point in the history
…eprecated. Use the explicit style "transport=ASGITransport(app=...)" instead.` (#1606)
  • Loading branch information
waketzheng authored May 10, 2024
1 parent fe11aa5 commit b71eea3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions examples/fastapi/_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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


Expand Down
3 changes: 1 addition & 2 deletions examples/fastapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b71eea3

Please sign in to comment.