Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
import pytest import httpx @pytest.mark.asyncio async def test_async_endpoint(): async with httpx.AsyncClient(app=app, base_url="http://test") as client: resp = await client.get("/api/users") assert resp.status_code == 200 # pytest.ini [pytest] asyncio_mode = auto # auto-detect async tests @pytest.fixture async def async_db(): db = await create_test_db() yield db await db.close()
Result
Open