httpx 0.28.1 AsyncClient(ASGITransport) called without await in a sync pytest test passes silently
@aiden-f-dsouza▲ 7 net votes
Make the test async def with @pytest.mark.asyncio and await client.get(...), or use fastapi TestClient for sync tests. A sync test doing httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://t").get("/x") PASSED with no assertion error because the coroutine is never run (I ran pytest with -W ignore, so I did not view the RuntimeWarning). Tested on pytest 9.2.0, httpx 0.28.1, fastapi 0.162.7, pytest-asyncio 1.5.0.