Skip to content

Commit 6b96345

Browse files
committed
fixup! Add stubs for hypothesis tests
1 parent 3576fc9 commit 6b96345

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

Lib/test/support/_hypothesis_stubs/__init__.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from enum import Enum
12
import functools
23
import unittest
34

@@ -14,8 +15,6 @@
1415
]
1516

1617
from . import strategies
17-
from ._settings import HealthCheck, Verbosity, settings
18-
from .control import assume, reject
1918

2019

2120
def given(*_args, **_kwargs):
@@ -29,6 +28,9 @@ def test_function(self):
2928
f(self, *example_args, **example_kwargs)
3029

3130
else:
31+
# If we have found no examples, we must skip the test. If @example
32+
# is applied after @given, it will re-wrap the test to remove the
33+
# skip decorator.
3234
test_function = unittest.skip(
3335
"Hypothesis required for property test with no " +
3436
"specified examples"
@@ -62,5 +64,39 @@ def decorator(f):
6264
return decorator
6365

6466

67+
def assume(condition):
68+
if not condition:
69+
raise unittest.SkipTest("Unsatisfied assumption")
70+
return True
71+
72+
73+
def reject():
74+
assume(False)
75+
76+
6577
def register_random(*args, **kwargs):
6678
pass # pragma: no cover
79+
80+
81+
def settings(*args, **kwargs):
82+
pass # pragma: nocover
83+
84+
85+
class HealthCheck(Enum):
86+
data_too_large = 1
87+
filter_too_much = 2
88+
too_slow = 3
89+
return_value = 5
90+
large_base_example = 7
91+
not_a_test_method = 8
92+
93+
@classmethod
94+
def all(cls):
95+
return list(cls)
96+
97+
98+
class Verbosity(Enum):
99+
quiet = 0
100+
normal = 1
101+
verbose = 2
102+
debug = 3

Lib/test/support/_hypothesis_stubs/control.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,3 @@
44
"reject",
55
"assume",
66
]
7-
8-
9-
def assume(condition):
10-
if not condition:
11-
raise unittest.SkipTest("Unsatisfied assumption")
12-
return True
13-
14-
15-
def reject():
16-
assume(False)

0 commit comments

Comments
 (0)