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

Function exit

src/_pytest/outcomes.py:116–143  ·  view source on GitHub ↗

Exit testing process. :param reason: The message to show as the reason for exiting pytest. reason has a default value only because `msg` is deprecated. :param returncode: Return code to be used when exiting pytest. :param msg: Same as ``reason``, but d

(
    reason: str = "", returncode: Optional[int] = None, *, msg: Optional[str] = None
)

Source from the content-addressed store, hash-verified

114
115@_with_exception(Exit)
116def exit(
117 reason: str = "", returncode: Optional[int] = None, *, msg: Optional[str] = None
118) -> "NoReturn":
119 """Exit testing process.
120
121 :param reason:
122 The message to show as the reason for exiting pytest. reason has a default value
123 only because `msg` is deprecated.
124
125 :param returncode:
126 Return code to be used when exiting pytest.
127
128 :param msg:
129 Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead.
130 """
131 __tracebackhide__ = True
132 from _pytest.config import UsageError
133
134 if reason and msg:
135 raise UsageError(
136 "cannot pass reason and msg to exit(), `msg` is deprecated, use `reason`."
137 )
138 if not reason:
139 if msg is None:
140 raise UsageError("exit() requires a reason argument")
141 warnings.warn(KEYWORD_MSG_ARG.format(func="exit"), stacklevel=2)
142 reason = msg
143 raise Exit(reason, returncode)
144
145
146@_with_exception(Skipped)

Callers 2

addErrorMethod · 0.90
get_issuesFunction · 0.85

Calls 4

UsageErrorClass · 0.90
ExitClass · 0.85
warnMethod · 0.45
formatMethod · 0.45

Tested by 1

addErrorMethod · 0.72