Skip to content

Commit 44e6d59

Browse files
committed
Split conftest.py
1 parent be34881 commit 44e6d59

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

array_api_tests/conftest.py

+1-37
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,25 @@
11
from functools import lru_cache
22

3-
from hypothesis import settings
43
from pytest import mark
54

65
from . import _array_module as xp
76
from ._array_module import _UndefinedStub
87

98

10-
settings.register_profile('xp_default', deadline=800)
11-
12-
139
def pytest_addoption(parser):
14-
# Enable extensions
1510
parser.addoption(
1611
'--ext',
1712
'--disable-extension',
1813
nargs='+',
1914
default=[],
2015
help='disable testing for Array API extension(s)',
2116
)
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-
)
3817

3918

4019
def pytest_configure(config):
4120
config.addinivalue_line(
4221
'markers', 'xp_extension(ext): tests an Array API extension'
4322
)
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')
5723

5824

5925
@lru_cache
@@ -75,8 +41,6 @@ def pytest_collection_modifyitems(config, items):
7541
continue
7642
ext = ext_mark.args[0]
7743
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'))
8145
elif not xp_has_ext(ext):
8246
item.add_marker(mark.skip(reason=f'{ext} not found in array module'))

conftest.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from hypothesis import settings
2+
3+
settings.register_profile('xp_default', deadline=800)
4+
5+
6+
def pytest_addoption(parser):
7+
# Hypothesis max examples
8+
# See https://github.com/HypothesisWorks/hypothesis/issues/2434
9+
parser.addoption(
10+
'--hypothesis-max-examples',
11+
'--max-examples',
12+
action='store',
13+
default=None,
14+
help='set the Hypothesis max_examples setting',
15+
)
16+
# Hypothesis deadline
17+
parser.addoption(
18+
'--hypothesis-disable-deadline',
19+
'--disable-deadline',
20+
action='store_true',
21+
help='disable the Hypothesis deadline',
22+
)
23+
24+
25+
def pytest_configure(config):
26+
hypothesis_max_examples = config.getoption('--hypothesis-max-examples')
27+
disable_deadline = config.getoption('--hypothesis-disable-deadline')
28+
profile_settings = {}
29+
if hypothesis_max_examples is not None:
30+
profile_settings['max_examples'] = int(hypothesis_max_examples)
31+
if disable_deadline is not None:
32+
profile_settings['deadline'] = None
33+
if profile_settings:
34+
settings.register_profile('xp_override', **profile_settings)
35+
settings.load_profile('xp_override')
36+
else:
37+
settings.load_profile('xp_default')

0 commit comments

Comments
 (0)