@@ -129,30 +129,27 @@ def pytest_collection_modifyitems(config, items):
129
129
id_ = line .strip ("\n " )
130
130
xfail_ids .append (id_ )
131
131
132
+ skip_id_matched = {id_ : False for id_ in skip_ids }
133
+ xfail_id_matched = {id_ : False for id_ in xfail_ids }
134
+
132
135
disabled_exts = config .getoption ("--disable-extension" )
133
136
disabled_dds = config .getoption ("--disable-data-dependent-shapes" )
134
137
ci = config .getoption ("--ci" )
135
- # skip if specified in skips file
136
- for id_ in skip_ids :
137
- for item in items :
138
- if id_ in item .nodeid :
139
- item .add_marker (mark .skip (reason = f"skips file ({ skips_file } )" ))
140
- break
141
- else :
142
- warnings .warn (f"Skip ID from { skips_file } doesn't appear to correspond to any tests: { id_ !r} " )
143
-
144
- # xfail if specified in xfails file
145
- for id_ in xfail_ids :
146
- for item in items :
147
- if id_ in item .nodeid :
148
- item .add_marker (mark .xfail (reason = f"xfails file ({ xfails_file } )" ))
149
- break
150
- else :
151
- warnings .warn (f"XFAIL ID from { xfails_file } doesn't appear to correspond to any tests: { id_ !r} " )
152
138
153
139
for item in items :
154
140
markers = list (item .iter_markers ())
155
-
141
+ # skip if specified in skips file
142
+ for id_ in skip_ids :
143
+ if item .nodeid .startswith (id_ ):
144
+ item .add_marker (mark .skip (reason = f"--skips-file ({ skips_file } )" ))
145
+ skip_id_matched [id_ ] = True
146
+ break
147
+ # xfail if specified in xfails file
148
+ for id_ in xfail_ids :
149
+ if item .nodeid .startswith (id_ ):
150
+ item .add_marker (mark .xfail (reason = f"--xfails-file ({ xfails_file } )" ))
151
+ xfail_id_matched [id_ ] = True
152
+ break
156
153
# skip if disabled or non-existent extension
157
154
ext_mark = next ((m for m in markers if m .name == "xp_extension" ), None )
158
155
if ext_mark is not None :
@@ -186,3 +183,26 @@ def pytest_collection_modifyitems(config, items):
186
183
reason = f"requires ARRAY_API_TESTS_VERSION=>{ min_version } "
187
184
)
188
185
)
186
+
187
+ bad_ids_end_msg = (
188
+ "Note the relevant tests might not of been collected by pytest, or "
189
+ "another specified id might have already matched a test."
190
+ )
191
+ bad_skip_ids = [id_ for id_ , matched in skip_id_matched .items () if not matched ]
192
+ if bad_skip_ids :
193
+ f_bad_ids = "\n " .join (f" { id_ } " for id_ in bad_skip_ids )
194
+ warnings .warn (
195
+ f"{ len (bad_skip_ids )} ids in skips file don't match any collected tests: \n "
196
+ f"{ f_bad_ids } \n "
197
+ f"(skips file: { skips_file } )\n "
198
+ f"{ bad_ids_end_msg } "
199
+ )
200
+ bad_xfail_ids = [id_ for id_ , matched in xfail_id_matched .items () if not matched ]
201
+ if bad_xfail_ids :
202
+ f_bad_ids = "\n " .join (f" { id_ } " for id_ in bad_xfail_ids )
203
+ warnings .warn (
204
+ f"{ len (bad_xfail_ids )} ids in xfails file don't match any collected tests: \n "
205
+ f"{ f_bad_ids } \n "
206
+ f"(xfails file: { xfails_file } )\n "
207
+ f"{ bad_ids_end_msg } "
208
+ )
0 commit comments