pytest-dev / pytest-dev/pytest

Option --last-failed with all prior failures filtered runs no tests

Open
#4,362 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: cache topic: collection topic: marks
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

When using --last-failed and there are no last failures, per default and as documented, all tests should run. That works fine unless combined with markers, if those filter all prior failures -> then it runs no tests. It would be more convenient if that could be detected, i.e. if all prior failures are filtered --lf should behave as if there had been NO last failures => rerun all.

pseudo - example:

$ pytest
... 1 test fails, which is marked 'bad'
... make some changes that will also fail another test 'later_bad' 
pytest --lf -m 'not bad'
... no tests are run, later_bad is not detected
... wanted behaviour: realize that all last failed are filtered => rerun all not-filtered tests, i.e. as without --lf

As a workaround I use:

pytest --lf -m 'not bad'
if [ "$?" == 5 ]; then pytest  -m 'not bad'

I am running pytest under Cygwin, and that is my version:

$ pytest --version
This is pytest version 3.8.2, imported from /usr/lib/python3.6/site-packages/pytest.py
setuptools registered plugins:
  pytest-cov-2.6.0 at /usr/lib/python3.6/site-packages/pytest_cov/plugin.py
PARSEER <class '_pytest.config.argparsing.Parser'>

Btw, thanks for the good work, pytest is great! If you are interested in my upgrade-feature request, I happily provide a full test case with py-code and shell script.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported pytest --lf -m 'not bad' behavior using the command-line options described in the issue. Trace how last-failed selection interacts with marker filtering, and verify that when every prior failure is filtered, the command runs all remaining tests as a normal run would.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.