Skip to content

Commit 76ba7db

Browse files
authored
Improve docs for last-failed-no-failures
Improve documentation for last-failed-no-failures to make the different options and the functionality more clear. Closes #11354
1 parent 941b203 commit 76ba7db

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

doc/en/how-to/cache.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,21 @@ with more recent files coming first.
176176
Behavior when no tests failed in the last run
177177
---------------------------------------------
178178

179-
When no tests failed in the last run, or when no cached ``lastfailed`` data was
180-
found, ``pytest`` can be configured either to run all of the tests or no tests,
181-
using the ``--last-failed-no-failures`` option, which takes one of the following values:
179+
The ``--lfnf/--last-failed-no-failures`` option governs the behavior of ``--last-failed``.
180+
Determines whether to execute tests when there are no previously (known)
181+
failures or when no cached ``lastfailed`` data was found.
182+
183+
There are two options:
184+
185+
* ``all``: when there are no known test failures, runs all tests (the full test suite). This is the default.
186+
* ``none``: when there are no known test failures, just emits a message stating this and exit successfully.
187+
188+
Example:
182189

183190
.. code-block:: bash
184191
185-
pytest --last-failed --last-failed-no-failures all # run all tests (default behavior)
186-
pytest --last-failed --last-failed-no-failures none # run no tests and exit
192+
pytest --last-failed --last-failed-no-failures all # runs the full test suite (default behavior)
193+
pytest --last-failed --last-failed-no-failures none # runs no tests and exits successfully
187194
188195
The new config.cache object
189196
--------------------------------

doc/en/reference/reference.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,8 +1892,11 @@ All the command-line flags can be obtained by running ``pytest --help``::
18921892
tests. Optional argument: glob (default: '*').
18931893
--cache-clear Remove all cache contents at start of test run
18941894
--lfnf={all,none}, --last-failed-no-failures={all,none}
1895-
Which tests to run with no previously (known)
1896-
failures
1895+
With ``--lf``, determines whether to execute tests when there
1896+
are no previously (known) failures or when no
1897+
cached ``lastfailed`` data was found.
1898+
``all`` (the default) runs the full test suite again.
1899+
``none`` just emits a message about no known failures and exits successfully.
18971900
--sw, --stepwise Exit on test failure and continue from last failing
18981901
test next time
18991902
--sw-skip, --stepwise-skip

src/_pytest/cacheprovider.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,11 @@ def pytest_addoption(parser: Parser) -> None:
499499
dest="last_failed_no_failures",
500500
choices=("all", "none"),
501501
default="all",
502-
help="Which tests to run with no previously (known) failures",
502+
help="With ``--lf``, determines whether to execute tests when there "
503+
"are no previously (known) failures or when no "
504+
"cached ``lastfailed`` data was found. "
505+
"``all`` (the default) runs the full test suite again. "
506+
"``none`` just emits a message about no known failures and exits successfully.",
503507
)
504508

505509

0 commit comments

Comments
 (0)