-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathconftest.py
More file actions
26 lines (22 loc) · 761 Bytes
/
conftest.py
File metadata and controls
26 lines (22 loc) · 761 Bytes
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
"""
pytest configuration to silently discard test items with invalid parameter combinations
See: https://github.com/pytest-dev/pytest/issues/3730#issuecomment-567142496
"""
def pytest_configure(config):
config.addinivalue_line(
"markers", "deselect_if(func): function to deselect tests from parametrization"
)
def pytest_collection_modifyitems(config, items):
removed = []
kept = []
for item in items:
m = item.get_closest_marker("deselect_if")
if m:
func = m.kwargs["func"]
if func(**item.callspec.params):
removed.append(item)
continue
kept.append(item)
if removed:
config.hook.pytest_deselected(items=removed)
items[:] = kept