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

Function fail

src/_pytest/outcomes.py:179–196  ·  view source on GitHub ↗

Explicitly fail an executing test with the given message. :param reason: The message to show the user as reason for the failure. :param pytrace: If False, msg represents the full failure information and no python traceback will be reported. :param msg:

(
    reason: str = "", pytrace: bool = True, msg: Optional[str] = None
)

Source from the content-addressed store, hash-verified

177
178@_with_exception(Failed)
179def fail(
180 reason: str = "", pytrace: bool = True, msg: Optional[str] = None
181) -> "NoReturn":
182 """Explicitly fail an executing test with the given message.
183
184 :param reason:
185 The message to show the user as reason for the failure.
186
187 :param pytrace:
188 If False, msg represents the full failure information and no
189 python traceback will be reported.
190
191 :param msg:
192 Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead.
193 """
194 __tracebackhide__ = True
195 reason = _resolve_msg_to_reason("fail", reason, msg)
196 raise Failed(msg=reason, pytrace=pytrace)
197
198
199def _resolve_msg_to_reason(

Callers 15

__exit__Method · 0.90
evaluate_conditionFunction · 0.90
assert_containsMethod · 0.90
popcallMethod · 0.90
_failMethod · 0.90
parametrizeMethod · 0.90
_validate_idsMethod · 0.90
getfuncargnamesFunction · 0.90
_check_scopeMethod · 0.90

Calls 2

_resolve_msg_to_reasonFunction · 0.85
FailedClass · 0.70

Tested by 5

assert_containsMethod · 0.72
popcallMethod · 0.72
_failMethod · 0.72
_addexcinfoMethod · 0.72
addUnexpectedSuccessMethod · 0.72