-
Notifications
You must be signed in to change notification settings - Fork 10
/
conftest.py
38 lines (31 loc) · 905 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
33
34
35
36
37
38
import pytest
def pytest_addoption(parser):
parser.addoption(
"--runslow",
action="store_true",
default=False,
help="run slow tests"
)
parser.addoption(
"--runslurm",
action="store_true",
default=False,
help="run slurm tests"
)
def pytest_configure(config):
config.addinivalue_line(
"markers", "slow: mark test as slow to run"
)
config.addinivalue_line(
"markers", "slurm: mark test which require slurm to run"
)
def pytest_collection_modifyitems(config, items):
def mark_skip(keyword):
if config.getoption(f"--run{keyword}"):
return
skip = pytest.mark.skip(reason=f"need --run{keyword} option to run")
for item in items:
if keyword in item.keywords:
item.add_marker(skip)
mark_skip("slow")
mark_skip("slurm")