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
)
| 114 | |
| 115 | @_with_exception(Exit) |
| 116 | def 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) |