From d5658f50958340ea0c4afea7c3f8ef0a51e50572 Mon Sep 17 00:00:00 2001 From: Fahrzin Hemmati Date: Mon, 23 Dec 2024 02:20:21 -0800 Subject: [PATCH] Check asyncio_mode (cheap) before _is_asyncio_fixture_function To fix https://github.com/pytest-dev/pytest-asyncio/issues/720 --- pytest_asyncio/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 12ead10f..48e53271 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -239,7 +239,7 @@ def _preprocess_async_fixtures( func ): continue - if not _is_asyncio_fixture_function(func) and asyncio_mode == Mode.STRICT: + if asyncio_mode == Mode.STRICT and not _is_asyncio_fixture_function(func): # Ignore async fixtures without explicit asyncio mark in strict mode # This applies to pytest_trio fixtures, for example continue @@ -969,9 +969,9 @@ def pytest_pyfunc_call(pyfuncitem: Function) -> object | None: # fixturedefs. The last entry in the list is closest and the one used. func = fixtures[-1].func if ( - _is_coroutine_or_asyncgen(func) + asyncio_mode == Mode.STRICT + and _is_coroutine_or_asyncgen(func) and not _is_asyncio_fixture_function(func) - and asyncio_mode == Mode.STRICT ): warnings.warn( PytestDeprecationWarning(