Skip to content

Commit 80442ae

Browse files
authored
Use False, instead of None as default for _XfailMarkDecorator's condition param and update doc (#11600)
1 parent 223e030 commit 80442ae

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ Saiprasad Kale
339339
Samuel Colvin
340340
Samuel Dion-Girardeau
341341
Samuel Searles-Bryant
342+
Samuel Therrien (Avasam)
342343
Samuele Pedroni
343344
Sanket Duthade
344345
Sankt Petersbug

changelog/11600.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

doc/en/reference/reference.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,11 @@ pytest.mark.xfail
239239

240240
Marks a test function as *expected to fail*.
241241

242-
.. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=xfail_strict)
242+
.. py:function:: pytest.mark.xfail(condition=False, *, reason=None, raises=None, run=True, strict=xfail_strict)
243243
244-
:type condition: bool or str
245-
:param condition:
244+
:keyword Union[bool, str] condition:
246245
Condition for marking the test function as xfail (``True/False`` or a
247-
:ref:`condition string <string conditions>`). If a bool, you also have
246+
:ref:`condition string <string conditions>`). If a ``bool``, you also have
248247
to specify ``reason`` (see :ref:`condition string <string conditions>`).
249248
:keyword str reason:
250249
Reason why the test function is marked as xfail.

src/_pytest/mark/structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def __call__(self, arg: Markable) -> Markable:
457457
@overload
458458
def __call__(
459459
self,
460-
condition: Union[str, bool] = ...,
460+
condition: Union[str, bool] = False,
461461
*conditions: Union[str, bool],
462462
reason: str = ...,
463463
run: bool = ...,

0 commit comments

Comments
 (0)