Evaluate xfail marks on item, returning Xfail if triggered.
(item: Item)
| 212 | |
| 213 | |
| 214 | def 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. |