From 080bc418bf16ed128dc119067a677e1adffb9607 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Sun, 14 Jul 2024 13:34:57 -0700 Subject: [PATCH] Upstreamed Hypothesis support --- newsfragments/143.misc.rst | 3 +++ pytest_trio/plugin.py | 15 +-------------- 2 files changed, 4 insertions(+), 14 deletions(-) create mode 100644 newsfragments/143.misc.rst diff --git a/newsfragments/143.misc.rst b/newsfragments/143.misc.rst new file mode 100644 index 0000000..f20319d --- /dev/null +++ b/newsfragments/143.misc.rst @@ -0,0 +1,3 @@ +Move some Hypothesis support into Trio itself, via the new plugins system. +As a result, ``pytest-trio`` will not import Hypothesis, while still +integrating seamlessly if _you_ import it. diff --git a/pytest_trio/plugin.py b/pytest_trio/plugin.py index 1a56a83..ebfcbee 100644 --- a/pytest_trio/plugin.py +++ b/pytest_trio/plugin.py @@ -1,4 +1,5 @@ """pytest-trio implementation.""" + import sys from functools import wraps, partial from collections.abc import Coroutine, Generator @@ -19,20 +20,6 @@ # Basic setup ################################################################ -try: - from hypothesis import register_random -except ImportError: # pragma: no cover - pass -else: - # On recent versions of Hypothesis, make the Trio scheduler deterministic - # even though it uses a module-scoped Random instance. This works - # regardless of whether or not the random_module strategy is used. - register_random(trio._core._run._r) - # We also have to enable determinism, which is disabled by default - # due to a small performance impact - but fine to enable in testing. - # See https://github.com/python-trio/trio/pull/890/ for details. - trio._core._run._ALLOW_DETERMINISTIC_SCHEDULING = True - def pytest_addoption(parser): parser.addini(