mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-26 18:35:05 +00:00
docs: explain FastAPI async fixture lifespan management
This commit is contained in:
1 parent
2353740d9e
commit
26b0523875
2 files changed
+6
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user