Skip to content

Commit 694ebe2

Browse files
committed
refactor: Extracted function determining whether a test function is a Hypothesis test.
Signed-off-by: Michael Seifert <[email protected]>
1 parent 2e2d5d2 commit 694ebe2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_asyncio/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def pytest_pyfunc_call(pyfuncitem):
288288
where the wrapped test coroutine is executed in an event loop.
289289
"""
290290
if "asyncio" in pyfuncitem.keywords:
291-
if getattr(pyfuncitem.obj, "is_hypothesis_test", False):
291+
if _is_hypothesis_test(pyfuncitem.obj):
292292
pyfuncitem.obj.hypothesis.inner_test = wrap_in_sync(
293293
pyfuncitem.obj.hypothesis.inner_test,
294294
_loop=pyfuncitem.funcargs["event_loop"],
@@ -300,6 +300,10 @@ def pytest_pyfunc_call(pyfuncitem):
300300
yield
301301

302302

303+
def _is_hypothesis_test(function) -> bool:
304+
return getattr(function, "is_hypothesis_test", False)
305+
306+
303307
def wrap_in_sync(func, _loop):
304308
"""Return a sync wrapper around an async function executing it in the
305309
current event loop."""

0 commit comments

Comments
 (0)