On Tue, 16 Jul 2024 at 10:09, Florian Schulze <m...@florian-schulze.net> wrote: > > On 16 Jul 2024, at 1:36, Oscar Benjamin wrote: > > > I like this idea. I would want it to have behaviour that > > --lf=failed.txt checks if the file exists and if not populates it with > > the contents from the pytest ---lf cache. Then you could do: > > > > $ pytest > > < runts tests, some fail > > > $ pytest --lf=failed=txt > > < file doesn't exist so save last-failed there (from > > .pytest_cache/last_failed) and run the failed tests > > > $ pytest --lf=failed.txt > > < file exists now so run tests specified in the file > > > Doing this based on the existence of the file causes a problem in my opinion. > Let's say I ran this before at some point and the file exists with an old set > of tests. Now I run the test suite and got new failures I want to store. I > forget to remove the file and run with --lf=failed.txt. Now the old set of > tests is used, the new set is gone and I have to re-run the whole suite, > which is exactly what I wanted to prevent in the first place.
There is always the possibility that you forget and run the wrong command. The downside of a stateful interface is that running the wrong command once potentially means you can't just fix the command and rerun. But --lf is already stateful and that is actually useful in practice because it means you can decide whether to use --lf after having seen the failures. You could also say that when run as --lf=failed.txt if the file exists then the cache doesn't get cleared. Then a subsequent run with --lf or --lf=failed2.txt still recovers the failing tests from the previous full run. -- Oscar _______________________________________________ pytest-dev mailing list pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev