3 ms·
> 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
by masklinn 4y ago
> 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.
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.
- johtso 4y agoOh nice, didn't know about that flag! Another option is to use a custom mark on the test you want to run, and then do something like "pytest -v -m onlyrunthis"