-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
conftest.py
32 lines (25 loc) · 901 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Global configuration for pytest"""
import numpy as np
import pytest
def pytest_addoption(parser):
parser.addoption(
"--regenerate-screenshots",
action="store_true",
dest="regenerate_screenshots",
default=False,
)
@pytest.fixture(autouse=True)
def predictable_random_numbers():
"""
Called at start of each test, guarantees that calls to random produce the same output over subsequent tests runs,
see https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.random.seed.html
"""
np.random.seed(0)
@pytest.fixture(autouse=True, scope="session")
def numerical_exceptions():
"""
Ensure any numerical errors raise a warning in our test suite
The point is that we enforce such cases to be handled explicitly in our code
Preferably using local `with np.errstate(...)` constructs
"""
np.seterr(all="raise")