I don't like pytest output
Pytest is a nice package to do unit tests in your python projects. However, its output is much too verbose, and I am not pleased with how it looks, because I’m not one of those developers who put their screen in portrait mode (I’d like to see you do that with a laptop :smile:).
This is what you get when a test fails, from a tutorial on Pluralsight:
_______________________________________________________________________________ test_menu_generate_menu_module3 _______________________________________________________________________________
tests/test_module3.py:222: in test_menu_generate_menu_module3
assert (
E AssertionError: Are you defining a function called `generate_menu` with the correct arguments?
E assert False
Note that this is one error. ONE! And it uses five lines, most of which is redundant
information. The heading is repeated in the next line, with a line number about
where the actual failing test is. However interesting that may be, this information
is usually not needed. Then there comes the line (which only has the assert
function call, totally irrelevant because that is how you test EVERYTHING),
then the real error and another totally irrelevant line telling us the assert
failed (well, d’oh, of course, the big E on the left should be enough of an
indication, and there is a line saying AssertionError
).
If there is any way to reduce the output (no, -quiet
doesn’t do it), I’d really
like to know. Failing that I plan to look at the inner workings of pytest and
write a small hook script or - hopefully not - fork off my own pytest module
to improve it.