File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ pytest-trio now makes the Trio scheduler deterministic while running
2+ inside a Hypothesis test. Hopefully you won't see any change, but if
3+ you had scheduler-dependent bugs Hypothesis will be more effective now.
Original file line number Diff line number Diff line change 2222 # Ordered dict (and **kwargs) not available with Python<3.6
2323 ORDERED_DICTS = False
2424
25+ try :
26+ from hypothesis import register_random
27+ except ImportError : # pragma: no cover
28+ pass
29+ else :
30+ # On recent versions of Hypothesis, make the Trio scheduler deterministic
31+ # even though it uses a module-scoped Random instance. This works
32+ # regardless of whether or not the random_module strategy is used.
33+ register_random (trio ._core ._run ._r )
34+
2535
2636def pytest_addoption (parser ):
2737 parser .addini (
@@ -345,7 +355,8 @@ def pytest_runtest_call(item):
345355 item .obj .hypothesis .inner_test = _trio_test_runner_factory (
346356 item , item .obj .hypothesis .inner_test
347357 )
348- elif getattr (item .obj , 'is_hypothesis_test' , False ):
358+ elif getattr (item .obj , 'is_hypothesis_test' ,
359+ False ): # pragma: no cover
349360 pytest .fail (
350361 'test function `%r` is using Hypothesis, but pytest-trio '
351362 'only works with Hypothesis 3.64.0 or later.' % item
You can’t perform that action at this time.
0 commit comments