Skip to content

Commit

Permalink
docs: updating the docs to make --lfnf more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
seanjedi committed Aug 28, 2023
1 parent 722b487 commit 75e815f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
13 changes: 5 additions & 8 deletions doc/en/how-to/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,14 @@ with more recent files coming first.
Behavior when no tests failed in the last run
---------------------------------------------

When no tests failed in the last run, or when no cached ``lastfailed`` data was
found, ``pytest`` can be configured either to run all of the tests or no tests,
using the ``--last-failed-no-failures`` option, which takes one of the following values:
This option governs the behavior of ``--last-failed``.
Determines whether to execute tests when there are no previously (known)
failures or when no cached ``lastfailed`` data was found.

.. code-block:: bash
pytest --last-failed --last-failed-no-failures all # run all tests (default behavior)
pytest --last-failed --last-failed-no-failures none # run no tests and exit
The ``--last-failed-no-failures`` option governs the behavior of ``--if``.
Default ``all`` runs all tests with no known failures. ``none`` avoids tests and exits successfully when there are no known failures.
pytest --last-failed --last-failed-no-failures all # run the full test suite again (default behavior)
pytest --last-failed --last-failed-no-failures none # runs no tests, emits a message about no known failures and exits successfully
The new config.cache object
--------------------------------
Expand Down
7 changes: 3 additions & 4 deletions doc/en/reference/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1892,12 +1892,11 @@ All the command-line flags can be obtained by running ``pytest --help``::
tests. Optional argument: glob (default: '*').
--cache-clear Remove all cache contents at start of test run
--lfnf={all,none}, --last-failed-no-failures={all,none}
Determines whether to execute tests when there
With ``--lf``, determines whether to execute tests when there
are no previously (known) failures or when no
cached ``lastfailed`` data was found.
This option governs the behavior of ``--if``.
Default ``all`` runs all tests with no known failures.
``none`` avoids tests and exits if no failures.
``all`` (the default) runs the full test suite again.
``none`` just emits a message about no known failures and exits successfully.
--sw, --stepwise Exit on test failure and continue from last failing
test next time
--sw-skip, --stepwise-skip
Expand Down
10 changes: 5 additions & 5 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,11 @@ def pytest_addoption(parser: Parser) -> None:
dest="last_failed_no_failures",
choices=("all", "none"),
default="all",
help="Determines whether to execute tests when there are no previously (known)"
"failures or when no cached ``lastfailed`` data was found."
"This option governs the behavior of ``--if``."
"Default ``all`` runs all tests with no known failures."
"``none`` avoids tests and exits if no failures.",
help="With ``--lf``, determines whether to execute tests when there"
"are no previously (known) failures or when no"
"cached ``lastfailed`` data was found."
"``all`` (the default) runs the full test suite again."
"``none`` just emits a message about no known failures and exits successfully.",
)


Expand Down

0 comments on commit 75e815f

Please sign in to comment.