MCPcopy
hub / github.com/pytest-dev/pytest / evaluate_xfail_marks

Function evaluate_xfail_marks

src/_pytest/skipping.py:214–240  ·  view source on GitHub ↗

Evaluate xfail marks on item, returning Xfail if triggered.

(item: Item)

Source from the content-addressed store, hash-verified

212
213
214def evaluate_xfail_marks(item: Item) -> Xfail | None:
215 """Evaluate xfail marks on item, returning Xfail if triggered."""
216 for mark in item.iter_markers(name="xfail"):
217 run = mark.kwargs.get("run", True)
218 strict = mark.kwargs.get("strict")
219 if strict is None:
220 strict = item.config.getini("strict_xfail")
221 if strict is None:
222 strict = item.config.getini("strict")
223 raises = mark.kwargs.get("raises", None)
224 if "condition" not in mark.kwargs:
225 conditions = mark.args
226 else:
227 conditions = (mark.kwargs["condition"],)
228
229 # Unconditional.
230 if not conditions:
231 reason = mark.kwargs.get("reason", "")
232 return Xfail(reason, run, strict, raises)
233
234 # If any of the conditions are true.
235 for condition in conditions:
236 result, reason = evaluate_condition(item, mark, condition)
237 if result:
238 return Xfail(reason, run, strict, raises)
239
240 return None
241
242
243# Saves the xfail mark evaluation. Can be refreshed during call if None.

Callers 3

pytest_runtest_setupFunction · 0.85
pytest_runtest_callFunction · 0.85

Calls 5

XfailClass · 0.85
evaluate_conditionFunction · 0.85
iter_markersMethod · 0.80
getMethod · 0.45
getiniMethod · 0.45

Tested by 1