Skip to content

Commit

Permalink
Use False, instead of None as default for _XfailMarkDecorator's…
Browse files Browse the repository at this point in the history
… `condition` param and update doc (#11600)
  • Loading branch information
Avasam committed Nov 17, 2023
1 parent 223e030 commit 80442ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ Saiprasad Kale
Samuel Colvin
Samuel Dion-Girardeau
Samuel Searles-Bryant
Samuel Therrien (Avasam)
Samuele Pedroni
Sanket Duthade
Sankt Petersbug
Expand Down
1 change: 1 addition & 0 deletions changelog/11600.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved the documentation and type signature for :func:`pytest.mark.xfail <pytest.mark.xfail>`'s ``condition`` param to use ``False`` as the default value.
7 changes: 3 additions & 4 deletions doc/en/reference/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,11 @@ pytest.mark.xfail

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=False, *, reason=None, raises=None, run=True, strict=xfail_strict)
:type condition: bool or str
:param condition:
:keyword Union[bool, str] condition:
Condition for marking the test function as xfail (``True/False`` or a
:ref:`condition string <string conditions>`). If a bool, you also have
:ref:`condition string <string conditions>`). If a ``bool``, you also have
to specify ``reason`` (see :ref:`condition string <string conditions>`).
:keyword str reason:
Reason why the test function is marked as xfail.
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def __call__(self, arg: Markable) -> Markable:
@overload
def __call__(
self,
condition: Union[str, bool] = ...,
condition: Union[str, bool] = False,
*conditions: Union[str, bool],
reason: str = ...,
run: bool = ...,
Expand Down

0 comments on commit 80442ae

Please sign in to comment.