File tree 2 files changed +38
-12
lines changed
Lib/test/support/_hypothesis_stubs 2 files changed +38
-12
lines changed Original file line number Diff line number Diff line change
1
+ from enum import Enum
1
2
import functools
2
3
import unittest
3
4
14
15
]
15
16
16
17
from . import strategies
17
- from ._settings import HealthCheck , Verbosity , settings
18
- from .control import assume , reject
19
18
20
19
21
20
def given (* _args , ** _kwargs ):
@@ -29,6 +28,9 @@ def test_function(self):
29
28
f (self , * example_args , ** example_kwargs )
30
29
31
30
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.
32
34
test_function = unittest .skip (
33
35
"Hypothesis required for property test with no " +
34
36
"specified examples"
@@ -62,5 +64,39 @@ def decorator(f):
62
64
return decorator
63
65
64
66
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
+
65
77
def register_random (* args , ** kwargs ):
66
78
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
Original file line number Diff line number Diff line change 4
4
"reject" ,
5
5
"assume" ,
6
6
]
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 )
You can’t perform that action at this time.
0 commit comments