Skip an executing test with the given message. This function should be called only during testing (setup, call or teardown) or during collection by using the ``allow_module_level`` flag. This function can be called in doctests as well. :param reason: The message to show th
(
reason: str = "", *, allow_module_level: bool = False, msg: Optional[str] = None
)
| 145 | |
| 146 | @_with_exception(Skipped) |
| 147 | def skip( |
| 148 | reason: str = "", *, allow_module_level: bool = False, msg: Optional[str] = None |
| 149 | ) -> "NoReturn": |
| 150 | """Skip an executing test with the given message. |
| 151 | |
| 152 | This function should be called only during testing (setup, call or teardown) or |
| 153 | during collection by using the ``allow_module_level`` flag. This function can |
| 154 | be called in doctests as well. |
| 155 | |
| 156 | :param reason: |
| 157 | The message to show the user as reason for the skip. |
| 158 | |
| 159 | :param allow_module_level: |
| 160 | Allows this function to be called at module level, skipping the rest |
| 161 | of the module. Defaults to False. |
| 162 | |
| 163 | :param msg: |
| 164 | Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead. |
| 165 | |
| 166 | .. note:: |
| 167 | It is better to use the :ref:`pytest.mark.skipif ref` marker when |
| 168 | possible to declare a test to be skipped under certain conditions |
| 169 | like mismatching platforms or dependencies. |
| 170 | Similarly, use the ``# doctest: +SKIP`` directive (see :py:data:`doctest.SKIP`) |
| 171 | to skip a doctest statically. |
| 172 | """ |
| 173 | __tracebackhide__ = True |
| 174 | reason = _resolve_msg_to_reason("skip", reason, msg) |
| 175 | raise Skipped(msg=reason, allow_module_level=allow_module_level) |
| 176 | |
| 177 | |
| 178 | @_with_exception(Failed) |