Merge pull request #11309 from bluetech/docs-xfail

doc: fix a few `xfail` nits
This commit is contained in:
Ran Benita 2023-08-12 18:58:37 +03:00 committed by GitHub
commit 10056865d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -237,7 +237,7 @@ pytest.mark.xfail
Marks a test function as *expected to fail*. Marks a test function as *expected to fail*.
.. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=False) .. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=xfail_strict)
:type condition: bool or str :type condition: bool or str
:param condition: :param condition:
@ -249,10 +249,10 @@ Marks a test function as *expected to fail*.
:keyword Type[Exception] raises: :keyword Type[Exception] raises:
Exception subclass (or tuple of subclasses) expected to be raised by the test function; other exceptions will fail the test. Exception subclass (or tuple of subclasses) expected to be raised by the test function; other exceptions will fail the test.
:keyword bool run: :keyword bool run:
If the test function should actually be executed. If ``False``, the function will always xfail and will Whether the test function should actually be executed. If ``False``, the function will always xfail and will
not be executed (useful if a function is segfaulting). not be executed (useful if a function is segfaulting).
:keyword bool strict: :keyword bool strict:
* If ``False`` (the default) the function will be shown in the terminal output as ``xfailed`` if it fails * If ``False`` the function will be shown in the terminal output as ``xfailed`` if it fails
and as ``xpass`` if it passes. In both cases this will not cause the test suite to fail as a whole. This and as ``xpass`` if it passes. In both cases this will not cause the test suite to fail as a whole. This
is particularly useful to mark *flaky* tests (tests that fail at random) to be tackled later. is particularly useful to mark *flaky* tests (tests that fail at random) to be tackled later.
* If ``True``, the function will be shown in the terminal output as ``xfailed`` if it fails, but if it * If ``True``, the function will be shown in the terminal output as ``xfailed`` if it fails, but if it
@ -260,6 +260,8 @@ Marks a test function as *expected to fail*.
that are always failing and there should be a clear indication if they unexpectedly start to pass (for example that are always failing and there should be a clear indication if they unexpectedly start to pass (for example
a new release of a library fixes a known bug). a new release of a library fixes a known bug).
Defaults to :confval:`xfail_strict`, which is ``False`` by default.
Custom marks Custom marks
~~~~~~~~~~~~ ~~~~~~~~~~~~

View File

@ -461,7 +461,9 @@ if TYPE_CHECKING:
*conditions: Union[str, bool], *conditions: Union[str, bool],
reason: str = ..., reason: str = ...,
run: bool = ..., run: bool = ...,
raises: Union[Type[BaseException], Tuple[Type[BaseException], ...]] = ..., raises: Union[
None, Type[BaseException], Tuple[Type[BaseException], ...]
] = ...,
strict: bool = ..., strict: bool = ...,
) -> MarkDecorator: ) -> MarkDecorator:
... ...

View File

@ -233,6 +233,9 @@ def xfail(reason: str = "") -> NoReturn:
This function should be called only during testing (setup, call or teardown). This function should be called only during testing (setup, call or teardown).
No other code is executed after using ``xfail()`` (it is implemented
internally by raising an exception).
:param reason: :param reason:
The message to show the user as reason for the xfail. The message to show the user as reason for the xfail.