-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
29 lines (25 loc) · 765 Bytes
/
conftest.py
File metadata and controls
29 lines (25 loc) · 765 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
import pytest
def pytest_runtest_call(item: pytest.Item):
# get not_supported marked
marker = item.get_closest_marker("not_supported")
not_implemented = False
if marker is None:
marker = item.get_closest_marker("not_implemented")
not_implemented = True
if marker is None:
# marked 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")