docs_src/async_tests/app_a_py310/test_main.py
raw| 1 | import pytest |
| 2 | from httpx import ASGITransport, AsyncClient |
| 3 | |
| 4 | from .main import app |
| 5 | |
| 6 | |
| 7 | @pytest.mark.anyio |
| 8 | async def test_root(): |
| 9 | async with AsyncClient( |
| 10 | transport=ASGITransport(app=app), base_url="http://test" |
| 11 | ) as ac: |
| 12 | response = await ac.get("/") |
| 13 | assert response.status_code == 200 |
| 14 | assert response.json() == {"message": "Tomato"} |