-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
31 lines (26 loc) · 829 Bytes
/
conftest.py
File metadata and controls
31 lines (26 loc) · 829 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
27
28
29
30
31
import pytest
def pytest_runtest_call(item: pytest.Item):
# get not_supported marker
marker: pytest.Mark | None = item.get_closest_marker("not_supported")
not_implemented: bool = False
if marker is None:
# get not_implemented marker
marker = item.get_closest_marker("not_implemented")
not_implemented = True
if marker is None:
# marker not found
return
try:
# run test
item.runtest()
except RuntimeError as e:
e_str = str(e).lower()
if "not supported" in e_str or "does not support" in e_str:
# Ok
pytest.xfail(str(e))
if not_implemented and "not implemented" in e_str:
pytest.xfail(str(e))
raise
else:
# fail test
pytest.fail("Expected test to fail")