Skip to content

Commit 5560526

Browse files
committed
refactor: Move Hypothesis version check to setup method of AsyncHypothesisTest.
1 parent 4ece0fa commit 5560526

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pytest_asyncio/plugin.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,6 @@ def setup(self) -> None:
462462
runner_fixture_id = f"_{self.loop_scope}_scoped_runner"
463463
if runner_fixture_id not in fixturenames:
464464
fixturenames.append(runner_fixture_id)
465-
if not getattr(self.obj, "hypothesis", False) and getattr(
466-
self.obj, "is_hypothesis_test", False
467-
):
468-
pytest.fail(
469-
f"test function `{self!r}` is using Hypothesis, but pytest-asyncio "
470-
"only works with Hypothesis 3.64.0 or later."
471-
)
472465
return super().setup()
473466

474467
def runtest(self) -> None:
@@ -545,6 +538,16 @@ class AsyncHypothesisTest(PytestAsyncioFunction):
545538
@hypothesis.given.
546539
"""
547540

541+
def setup(self) -> None:
542+
if not getattr(self.obj, "hypothesis", False) and getattr(
543+
self.obj, "is_hypothesis_test", False
544+
):
545+
pytest.fail(
546+
f"test function `{self!r}` is using Hypothesis, but pytest-asyncio "
547+
"only works with Hypothesis 3.64.0 or later."
548+
)
549+
return super().setup()
550+
548551
@staticmethod
549552
def _can_substitute(item: Function) -> bool:
550553
func = item.obj

0 commit comments

Comments
 (0)