From e6867c729af5768bbe290518640aed6d51b11ce5 Mon Sep 17 00:00:00 2001 From: Matthew Schinckel Date: Tue, 6 Feb 2024 10:55:42 +1030 Subject: [PATCH] Adds note about sync-only calls in async decorators. --- docs/topics/testing/tools.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 14a58c4c00..89c15d10fa 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -2087,7 +2087,9 @@ creates. If you are using test decorators, they must be async-compatible to ensure they work correctly. Django's built-in decorators will behave correctly, but third-party ones may appear to not execute (they will "wrap" the wrong part - of the execution flow and not your test). + of the execution flow and not your test). Similarly, decorators that perform + synchronous database operations cannot be applied directly to an async test + function. If you need to use these decorators, then you should decorate your test methods with :func:`~asgiref.sync.async_to_sync` *inside* of them instead::