From c546a7e6b77361ad54af7b96eee2ac462728c88b Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 29 Aug 2024 16:20:04 -0400 Subject: [PATCH] Switch to `inspect.iscoroutinefunction` over `asyncio.iscoroutinefunction` --- 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 178fcaa6..b2a8fef5 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -176,7 +176,7 @@ def _make_asyncio_fixture_function( def _is_coroutine_or_asyncgen(obj: Any) -> bool: - return asyncio.iscoroutinefunction(obj) or inspect.isasyncgenfunction(obj) + return inspect.iscoroutinefunction(obj) or inspect.isasyncgenfunction(obj) def _get_asyncio_mode(config: Config) -> Mode: @@ -447,7 +447,7 @@ class Coroutine(PytestAsyncioFunction): @staticmethod def _can_substitute(item: Function) -> bool: func = item.obj - return asyncio.iscoroutinefunction(func) + return inspect.iscoroutinefunction(func) def runtest(self) -> None: self.obj = wrap_in_sync( @@ -512,7 +512,7 @@ def _can_substitute(item: Function) -> bool: return ( getattr(func, "is_hypothesis_test", False) # type: ignore[return-value] and getattr(func, "hypothesis", None) - and asyncio.iscoroutinefunction(func.hypothesis.inner_test) + and inspect.iscoroutinefunction(func.hypothesis.inner_test) ) def runtest(self) -> None: