]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Add warning about lifecycle events with `AsyncClient` (#4167)
authorAndrew Chang-DeWitt <11323923+andrew-chang-dewitt@users.noreply.github.com>
Tue, 9 Jan 2024 17:45:52 +0000 (11:45 -0600)
committerGitHub <noreply@github.com>
Tue, 9 Jan 2024 17:45:52 +0000 (21:45 +0400)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
docs/en/docs/advanced/async-tests.md

index 9b39d70fca6a8e82257282598ab87b41224fa4b4..c79822d63e19b4d95222caf50da0034f11123e01 100644 (file)
@@ -84,6 +84,9 @@ response = client.get('/')
 !!! tip
     Note that we're using async/await with the new `AsyncClient` - the request is asynchronous.
 
+!!! warning
+    If your application relies on lifespan events, the `AsyncClient` won't trigger these events. To ensure they are triggered, use `LifespanManager` from <a href="florimondmanca/asgi-lifespan" class="external-link" target="_blank">https://github.com/florimondmanca/asgi-lifespan#usage</a>.
+
 ## Other Asynchronous Function Calls
 
 As the testing function is now asynchronous, you can now also call (and `await`) other `async` functions apart from sending requests to your FastAPI application in your tests, exactly as you would call them anywhere else in your code.