mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-24 09:44:01 -04:00
📝 Fix async test example not to trigger DeprecationWarning (#12084)
This commit is contained in:
committed by
GitHub
parent
17a29149e4
commit
6e98249c21
@@ -1,12 +1,14 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
from .main import app
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_root():
|
||||
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||
async with AsyncClient(
|
||||
transport=ASGITransport(app=app), base_url="http://test"
|
||||
) as ac:
|
||||
response = await ac.get("/")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"message": "Tomato"}
|
||||
|
||||
Reference in New Issue
Block a user