MCPcopy Create free account
hub / github.com/pytest-dev/pytest / evaluate_skip_marks

Function evaluate_skip_marks

src/_pytest/skipping.py:167–192  ·  view source on GitHub ↗

Evaluate skip and skipif marks on item, returning Skip if triggered.

(item: Item)

Source from the content-addressed store, hash-verified

165
166
167def evaluate_skip_marks(item: Item) -> Optional[Skip]:
168 """Evaluate skip and skipif marks on item, returning Skip if triggered."""
169 for mark in item.iter_markers(name="skipif"):
170 if "condition" not in mark.kwargs:
171 conditions = mark.args
172 else:
173 conditions = (mark.kwargs["condition"],)
174
175 # Unconditional.
176 if not conditions:
177 reason = mark.kwargs.get("reason", "")
178 return Skip(reason)
179
180 # If any of the conditions are true.
181 for condition in conditions:
182 result, reason = evaluate_condition(item, mark, condition)
183 if result:
184 return Skip(reason)
185
186 for mark in item.iter_markers(name="skip"):
187 try:
188 return Skip(*mark.args, **mark.kwargs)
189 except TypeError as e:
190 raise TypeError(str(e) + " - maybe you meant pytest.mark.skipif?") from None
191
192 return None
193
194
195@attr.s(slots=True, frozen=True, auto_attribs=True)

Calls 4

SkipClass · 0.85
evaluate_conditionFunction · 0.85
iter_markersMethod · 0.80
getMethod · 0.45