forked from pybamm-team/PyBaMM
-
Notifications
You must be signed in to change notification settings - Fork 5
/
conftest.py
53 lines (43 loc) · 1.38 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pytest
import numpy as np
import pybamm
def pytest_addoption(parser):
parser.addoption(
"--scripts",
action="store_true",
default=False,
help="execute the example scripts",
)
parser.addoption(
"--unit", action="store_true", default=False, help="run unit tests"
)
parser.addoption(
"--integration",
action="store_true",
default=False,
help="run integration tests",
)
parser.addoption(
"--cibw",
action="store_true",
default=False,
help="test build wheels",
)
def pytest_configure(config):
config.addinivalue_line("markers", "scripts: mark test as an example script")
config.addinivalue_line("markers", "unit: mark test as a unit test")
config.addinivalue_line("markers", "integration: mark test as an integration test")
config.addinivalue_line("markers", "cibw: mark test as build wheel test")
def pytest_collection_modifyitems(items):
for item in items:
if "unit" in item.nodeid:
item.add_marker(pytest.mark.unit)
elif "integration" in item.nodeid:
item.add_marker(pytest.mark.integration)
@pytest.fixture(autouse=True)
# Set the random seed to 42 for all tests
def set_random_seed():
np.random.seed(42)
@pytest.fixture(autouse=True)
def set_debug_value():
pybamm.settings.debug_mode = True