From a73705f40fce7ab861ccf7c56f58b188b206429e Mon Sep 17 00:00:00 2001 From: Aziztaamalli Date: Wed, 8 Jul 2026 14:25:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Fix=20outdated=20on=5Fevent=20re?= =?UTF-8?q?ference=20in=20async=20tests=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The async tests page told readers to instantiate event-loop-bound objects inside an `@app.on_event("startup")` callback, but `on_event` is deprecated in favor of `lifespan` (as documented on the Lifespan Events page, and as this same page already references a few lines above when discussing lifespan events with the AsyncClient). --- docs/en/docs/advanced/async-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/docs/advanced/async-tests.md b/docs/en/docs/advanced/async-tests.md index c7ec5e9e2..9b8a34dae 100644 --- a/docs/en/docs/advanced/async-tests.md +++ b/docs/en/docs/advanced/async-tests.md @@ -94,6 +94,6 @@ As the testing function is now asynchronous, you can now also call (and `await`) /// tip -If you encounter a `RuntimeError: Task attached to a different loop` when integrating asynchronous function calls in your tests (e.g. when using [MongoDB's MotorClient](https://stackoverflow.com/questions/41584243/runtimeerror-task-attached-to-a-different-loop)), remember to instantiate objects that need an event loop only within async functions, e.g. an `@app.on_event("startup")` callback. +If you encounter a `RuntimeError: Task attached to a different loop` when integrating asynchronous function calls in your tests (e.g. when using [MongoDB's MotorClient](https://stackoverflow.com/questions/41584243/runtimeerror-task-attached-to-a-different-loop)), remember to instantiate objects that need an event loop only within async functions, e.g. an async `lifespan` handler. ///