Skip to content

Commit 9453490

Browse files
committed
Rename xfail_strict to strict_xfail, make it an alias
This is to make it consistent with the other `strict_` options. For #13823.
1 parent d5a0057 commit 9453490

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

changelog/13823.improvement.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added :confval:`strict_xfail` as an alias to the ``xfail_strict`` option.
2+
This makes it consistent with other strictness options.

doc/en/how-to/skipping.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ You can change this by setting the ``strict`` keyword-only parameter to ``True``
331331
This will make ``XPASS`` ("unexpectedly passing") results from this test to fail the test suite.
332332

333333
You can change the default value of the ``strict`` parameter using the
334-
``xfail_strict`` ini option:
334+
``strict_xfail`` ini option:
335335

336336
.. code-block:: ini
337337
338338
[pytest]
339-
xfail_strict=true
339+
strict_xfail=true
340340
341341
342342
Ignoring xfail

doc/en/reference/reference.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ pytest.mark.xfail
261261

262262
Marks a test function as *expected to fail*.
263263

264-
.. py:function:: pytest.mark.xfail(condition=False, *, reason=None, raises=None, run=True, strict=xfail_strict)
264+
.. py:function:: pytest.mark.xfail(condition=False, *, reason=None, raises=None, run=True, strict=strict_xfail)
265265
266266
:keyword Union[bool, str] condition:
267267
Condition for marking the test function as xfail (``True/False`` or a
@@ -286,7 +286,7 @@ Marks a test function as *expected to fail*.
286286
that are always failing and there should be a clear indication if they unexpectedly start to pass (for example
287287
a new release of a library fixes a known bug).
288288

289-
Defaults to :confval:`xfail_strict`, which is ``False`` by default.
289+
Defaults to :confval:`strict_xfail`, which is ``False`` by default.
290290

291291

292292
Custom marks
@@ -2070,7 +2070,7 @@ passed multiple times. The expected format is ``name=value``. For example::
20702070
"auto" can be used to explicitly use the global verbosity level.
20712071

20722072

2073-
.. confval:: xfail_strict
2073+
.. confval:: strict_xfail
20742074

20752075
If set to ``True``, tests marked with ``@pytest.mark.xfail`` that actually succeed will by default fail the
20762076
test suite.
@@ -2080,7 +2080,11 @@ passed multiple times. The expected format is ``name=value``. For example::
20802080
.. code-block:: ini
20812081
20822082
[pytest]
2083-
xfail_strict = True
2083+
strict_xfail = True
2084+
2085+
.. versionchanged:: 9.0
2086+
Renamed from ``xfail_strict`` to ``strict_xfail``.
2087+
``xfail_strict`` is accepted as an alias for ``strict_xfail``.
20842088

20852089
.. confval:: strict_parametrization_ids
20862090

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ norecursedirs = [
378378
"build",
379379
"dist",
380380
]
381-
xfail_strict = true
381+
strict_xfail = true
382382
strict_parametrization_ids = true
383383
filterwarnings = [
384384
"error",

src/_pytest/helpconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def pytest_addoption(parser: Parser) -> None:
103103
dest="override_ini",
104104
action="append",
105105
help='Override ini option with "option=value" style, '
106-
"e.g. `-o xfail_strict=True -o cache_dir=cache`.",
106+
"e.g. `-o strict_xfail=True -o cache_dir=cache`.",
107107
)
108108

109109

src/_pytest/skipping.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ def pytest_addoption(parser: Parser) -> None:
3737
)
3838

3939
parser.addini(
40-
"xfail_strict",
40+
"strict_xfail",
4141
"Default for the strict parameter of xfail "
42-
"markers when not given explicitly (default: False)",
42+
"markers when not given explicitly (default: False) (alias: xfail_strict)",
4343
default=False,
4444
type="bool",
45+
aliases=["xfail_strict"],
4546
)
4647

4748

@@ -74,7 +75,7 @@ def nop(*args, **kwargs):
7475
)
7576
config.addinivalue_line(
7677
"markers",
77-
"xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): "
78+
"xfail(condition, ..., *, reason=..., run=True, raises=None, strict=strict_xfail): "
7879
"mark the test function as an expected failure if any of the conditions "
7980
"evaluate to True. Optionally specify a reason for better reporting "
8081
"and run=False if you don't even want to execute the test function. "
@@ -213,7 +214,7 @@ def evaluate_xfail_marks(item: Item) -> Xfail | None:
213214
"""Evaluate xfail marks on item, returning Xfail if triggered."""
214215
for mark in item.iter_markers(name="xfail"):
215216
run = mark.kwargs.get("run", True)
216-
strict = mark.kwargs.get("strict", item.config.getini("xfail_strict"))
217+
strict = mark.kwargs.get("strict", item.config.getini("strict_xfail"))
217218
raises = mark.kwargs.get("raises", None)
218219
if "condition" not in mark.kwargs:
219220
conditions = mark.args

testing/test_skipping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ def test_strict_xfail_default_from_file(
690690
pytester.makeini(
691691
f"""
692692
[pytest]
693-
xfail_strict = {strict_val}
693+
strict_xfail = {strict_val}
694694
"""
695695
)
696696
p = pytester.makepyfile(
@@ -1178,7 +1178,7 @@ def test_default_markers(pytester: Pytester) -> None:
11781178
result.stdout.fnmatch_lines(
11791179
[
11801180
"*skipif(condition, ..., [*], reason=...)*skip*",
1181-
"*xfail(condition, ..., [*], reason=..., run=True, raises=None, strict=xfail_strict)*expected failure*",
1181+
"*xfail(condition, ..., [*], reason=..., run=True, raises=None, strict=strict_xfail)*expected failure*",
11821182
]
11831183
)
11841184

0 commit comments

Comments
 (0)