docs: explain FastAPI async fixture lifespan management

This commit is contained in:
Eneko Ruiz committed 2026-10-16 15:14:12 +02:00
1 parent 2353740d9e
commit 26b0523875
2 files changed
+6

No files matched your search

+3
View File
@@ -486,6 +486,9 @@ async def test_async_with_fixture(async_client):
### Async Fixture (FastAPI)
`ASGITransport` does not run lifespan events. If the app needs startup/shutdown, wrap the client block in `async with LifespanManager(app) as manager:` (from `asgi_lifespan`)
and use `ASGITransport(app=manager.app)`. See [FastAPI's async testing guidance](https://github.com/fastapi/fastapi/blob/master/docs/en/docs/advanced/async-tests.md).
```python
import pytest
import pytest_asyncio
+3
View File
@@ -486,6 +486,9 @@ async def test_async_with_fixture(async_client):
### Async Fixture (FastAPI)
`ASGITransport` does not run lifespan events. If the app needs startup/shutdown, wrap the client block in `async with LifespanManager(app) as manager:` (from `asgi_lifespan`)
and use `ASGITransport(app=manager.app)`. See [FastAPI's async testing guidance](https://github.com/fastapi/fastapi/blob/master/docs/en/docs/advanced/async-tests.md).
```python
import pytest
import pytest_asyncio