News for hackers. Stuff that matters.
Re:Stop requiring only one assertion per unit test: Multiple... by johtso on Saturday November 05, 2022 @08:44AM (#33480880)
Again pytest makes things so much nicer in this regard. Having to comment things out sucks.

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.

Re:Stop requiring only one assertion per unit test: Multiple... by masklinn on Saturday November 05, 2022 @08:59AM (#33480982)
> 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.

Re:Stop requiring only one assertion per unit test: Multiple... by johtso on Monday November 07, 2022 @12:31PM (#33509055)
Oh 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"