With pytest you can use the -x flag to stop after the first test failure.
Even better you can use that in combination with -lf to only run the last failed test.
With pytest you can use the -x flag to stop after the first test failure.
Even better you can use that in combination with -lf to only run the last failed test.
> Even better you can use that in combination with -lf to only run the last failed test.
Fwiw `--sw` is much better for that specific use-case.
`--lf` is more useful to run the entire test suite, then re-run just the failed tests (of the entire suite). IIRC it can have some odd interactions with `-x` or `--maxfail`, because the strange things happen to the cached "selected set".
Though it may also be because I use xdist a fair bit, and the interaction of xdist with early interruptions (x, maxfail, ...) seems less than perfect.
Another option is to use a custom mark on the test you want to run, and then do something like "pytest -v -m onlyrunthis"