Evaluate xfail marks on item, returning Xfail if triggered.
(item: Item)
| 203 | |
| 204 | |
| 205 | def evaluate_xfail_marks(item: Item) -> Optional[Xfail]: |
| 206 | """Evaluate xfail marks on item, returning Xfail if triggered.""" |
| 207 | for mark in item.iter_markers(name="xfail"): |
| 208 | run = mark.kwargs.get("run", True) |
| 209 | strict = mark.kwargs.get("strict", item.config.getini("xfail_strict")) |
| 210 | raises = mark.kwargs.get("raises", None) |
| 211 | if "condition" not in mark.kwargs: |
| 212 | conditions = mark.args |
| 213 | else: |
| 214 | conditions = (mark.kwargs["condition"],) |
| 215 | |
| 216 | # Unconditional. |
| 217 | if not conditions: |
| 218 | reason = mark.kwargs.get("reason", "") |
| 219 | return Xfail(reason, run, strict, raises) |
| 220 | |
| 221 | # If any of the conditions are true. |
| 222 | for condition in conditions: |
| 223 | result, reason = evaluate_condition(item, mark, condition) |
| 224 | if result: |
| 225 | return Xfail(reason, run, strict, raises) |
| 226 | |
| 227 | return None |
| 228 | |
| 229 | |
| 230 | # Saves the xfail mark evaluation. Can be refreshed during call if None. |