-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
31 lines (24 loc) · 1.02 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
import pytest
optional_markers = {
"devtest": {
"help": "run all tests including those for test-driven dev.",
"description": "test is relevant for test-drive development only.",
"skip-reason": "only ran during development, use --{marker} to run."
}
}
def pytest_addoption(parser):
for marker, info in optional_markers.items():
parser.addoption(f"--{marker}", action="store_true", default=False,
help=info['help'])
def pytest_configure(config):
for marker, info in optional_markers.items():
config.addinivalue_line("markers", f"{marker}: {info['description']}")
def pytest_collection_modifyitems(config, items):
for marker, info in optional_markers.items():
if not config.getoption(f"--{marker}"):
skip_devtest = pytest.mark.skip(
reason=info['skip-reason'].format(marker=marker)
)
for item in items:
if marker in item.keywords:
item.add_marker(skip_devtest)