Skip to content

Commit 44c7498

Browse files
committed
Warn if a skip or xfail from a file doesn't correspond to any tests
1 parent d7b457a commit 44c7498

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

conftest.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from functools import lru_cache
22
from pathlib import Path
3+
import warnings
34

45
from hypothesis import settings
56
from pytest import mark
@@ -125,18 +126,27 @@ def pytest_collection_modifyitems(config, items):
125126
disabled_exts = config.getoption("--disable-extension")
126127
disabled_dds = config.getoption("--disable-data-dependent-shapes")
127128
ci = config.getoption("--ci")
128-
for item in items:
129-
markers = list(item.iter_markers())
130-
# skip if specified in skips file
131-
for id_ in skip_ids:
129+
# skip if specified in skips file
130+
for id_ in skip_ids:
131+
for item in items:
132132
if id_ in item.nodeid:
133133
item.add_marker(mark.skip(reason=f"skips file ({skips_file})"))
134134
break
135-
# xfail if specified in xfails file
136-
for id_ in xfail_ids:
135+
else:
136+
warnings.warn(f"Skip ID from {skips_file} doesn't appear to correspond to any tests: {id_!r}")
137+
138+
# xfail if specified in xfails file
139+
for id_ in xfail_ids:
140+
for item in items:
137141
if id_ in item.nodeid:
138142
item.add_marker(mark.xfail(reason=f"xfails file ({xfails_file})"))
139143
break
144+
else:
145+
warnings.warn(f"XFAIL ID from {xfails_file} doesn't appear to correspond to any tests: {id_!r}")
146+
147+
for item in items:
148+
markers = list(item.iter_markers())
149+
140150
# skip if disabled or non-existent extension
141151
ext_mark = next((m for m in markers if m.name == "xp_extension"), None)
142152
if ext_mark is not None:

0 commit comments

Comments
 (0)