Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--last-failed and retest on success #76

Open
carver opened this issue Oct 3, 2017 · 7 comments
Open

--last-failed and retest on success #76

carver opened this issue Oct 3, 2017 · 7 comments

Comments

@carver
Copy link

carver commented Oct 3, 2017

I'd love some guidance on how to get pytest --last-failed to play nice with ptw. Right now, if the last failed tests succeeds, then ptw sits patiently until the next file change.

What I'd like is for it to run normally with last-failed, but when all of the last-failed tests succeed, then rerun all tests. Any suggestions?

@max-sixty
Copy link

Agree, this would be a great config. This would match the --looponfail behavior

@carver
Copy link
Author

carver commented Oct 7, 2018

The workaround I've been using is ptw mymodule/ tests/ -- --failed-first --exitfirst in order to quickly re-loop on failing tests, but run all the remaining tests. ( or ptw mymodule tests -- --ff -x for the code golfers)

@max-sixty
Copy link

@carver that's a great idea.

To confirm - -x runs one failed test, not all the failed tests; is that correct?

@carver
Copy link
Author

carver commented Oct 8, 2018

-x halts at the first failed test, which may mean that multiple previously failing tests are run (if they start passing).

@max-sixty
Copy link

Yes, and then the next iteration runs only that single test, as opposed to looping over the failed tests?

@carver
Copy link
Author

carver commented Oct 8, 2018

Say you have tests A, B, C, D, run in that order. Then you break tests B-D.

The next run is:

  • A - pass
  • B - fail
  • halt

Then you try to fix, but don't succeed. The next run is:

  • B - fail
  • halt

Then you fix B. The next run is:

  • B - pass
  • A - pass
  • C - fail
  • halt

@max-sixty
Copy link

Perfect, thanks for clarifying.

For comparison, --looponfail would do:

  • A - pass
  • B - fail
  • C - fail
  • D - fail

Then you try to fix [B], but don't succeed. The next run is:

  • B - fail
  • C - fail
  • D - fail

Then you fix B. The next run is:

  • B - pass
  • C - fail
  • D - fail

...each run runs all the still-failing tests, until they're all fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants