Accept `None` in `_XfailMarkDecorator`'s `condition`param and expose default value

This commit is contained in:
Avasam 2023-10-27 18:26:29 -04:00
parent 738ae2da9d
commit 21e78b7bce
4 changed files with 8 additions and 7 deletions

View File

@ -338,6 +338,7 @@ Saiprasad Kale
Samuel Colvin Samuel Colvin
Samuel Dion-Girardeau Samuel Dion-Girardeau
Samuel Searles-Bryant Samuel Searles-Bryant
Samuel Therrien (Avasam)
Samuele Pedroni Samuele Pedroni
Sanket Duthade Sanket Duthade
Sankt Petersbug Sankt Petersbug

View File

@ -0,0 +1 @@
Improved the documentation and type signature for :func:`pytest.mark.xfail <pytest.mark.xfail>`'s ``condition`` param to support ``None``.

View File

@ -239,11 +239,10 @@ Marks a test function as *expected to fail*.
.. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=xfail_strict) .. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=xfail_strict)
:type condition: bool or str :keyword Optional[Union[bool, str]] condition:
:param condition: Condition for marking the test function as xfail (``True/False/None`` or a
Condition for marking the test function as xfail (``True/False`` or a :ref:`condition string <string conditions>`). If a bool or None, you also have
:ref:`condition string <string conditions>`). If a bool, you also have to specify ``reason`` (see :ref:`condition string <string conditions>`). ``None`` is the same as ``False``.
to specify ``reason`` (see :ref:`condition string <string conditions>`).
:keyword str reason: :keyword str reason:
Reason why the test function is marked as xfail. Reason why the test function is marked as xfail.
:keyword Type[Exception] raises: :keyword Type[Exception] raises:

View File

@ -457,8 +457,8 @@ if TYPE_CHECKING:
@overload @overload
def __call__( def __call__(
self, self,
condition: Union[str, bool] = ..., condition: Optional[Union[str, bool]] = None,
*conditions: Union[str, bool], *conditions: Optional[Union[str, bool]],
reason: str = ..., reason: str = ...,
run: bool = ..., run: bool = ...,
raises: Union[ raises: Union[