1
1
from functools import lru_cache
2
2
3
- from hypothesis import settings
4
3
from pytest import mark
5
4
6
5
from . import _array_module as xp
7
6
from ._array_module import _UndefinedStub
8
7
9
8
10
- settings .register_profile ('xp_default' , deadline = 800 )
11
-
12
-
13
9
def pytest_addoption (parser ):
14
- # Enable extensions
15
10
parser .addoption (
16
11
'--ext' ,
17
12
'--disable-extension' ,
18
13
nargs = '+' ,
19
14
default = [],
20
15
help = 'disable testing for Array API extension(s)' ,
21
16
)
22
- # Hypothesis max examples
23
- # See https://github.com/HypothesisWorks/hypothesis/issues/2434
24
- parser .addoption (
25
- '--hypothesis-max-examples' ,
26
- '--max-examples' ,
27
- action = 'store' ,
28
- default = None ,
29
- help = 'set the Hypothesis max_examples setting' ,
30
- )
31
- # Hypothesis deadline
32
- parser .addoption (
33
- '--hypothesis-disable-deadline' ,
34
- '--disable-deadline' ,
35
- action = 'store_true' ,
36
- help = 'disable the Hypothesis deadline' ,
37
- )
38
17
39
18
40
19
def pytest_configure (config ):
41
20
config .addinivalue_line (
42
21
'markers' , 'xp_extension(ext): tests an Array API extension'
43
22
)
44
- # Configure Hypothesis
45
- hypothesis_max_examples = config .getoption ('--hypothesis-max-examples' )
46
- disable_deadline = config .getoption ('--hypothesis-disable-deadline' )
47
- profile_settings = {}
48
- if hypothesis_max_examples is not None :
49
- profile_settings ['max_examples' ] = int (hypothesis_max_examples )
50
- if disable_deadline is not None :
51
- profile_settings ['deadline' ] = None
52
- if profile_settings :
53
- settings .register_profile ('xp_override' , ** profile_settings )
54
- settings .load_profile ('xp_override' )
55
- else :
56
- settings .load_profile ('xp_default' )
57
23
58
24
59
25
@lru_cache
@@ -75,8 +41,6 @@ def pytest_collection_modifyitems(config, items):
75
41
continue
76
42
ext = ext_mark .args [0 ]
77
43
if ext in disabled_exts :
78
- item .add_marker (
79
- mark .skip (reason = f'{ ext } disabled in --disable-extensions' )
80
- )
44
+ item .add_marker (mark .skip (reason = f'{ ext } disabled in --disable-extensions' ))
81
45
elif not xp_has_ext (ext ):
82
46
item .add_marker (mark .skip (reason = f'{ ext } not found in array module' ))
0 commit comments