[TIP] pytest-sugar -> pytest

Stefan Scherfke stefan at sofa-rockers.org
Wed Sep 19 03:22:59 PDT 2018

Am 2018-09-19 um 11:37 schrieb Florian Bruhin <me at the-compiler.org>:
> On Wed, Sep 19, 2018 at 11:08:03AM +0200, Stefan Scherfke wrote:
>> I think it might make sense to merge/integrate pytest-sugar into pytest
>> (or just modify pytest’s default output format).  What do you think?
> -1 from my side. I've seen it fail in funny ways in some special
> terminals (even unicode output can be problematic). I'd rather have a
> default output which actually works in various scenarios.

Okay, I can understand that.

> I think smaller incremental changes (like the progress output which was
> added) are nice, but pytest-sugar as a whole comes with too many
> gotchas.

Then about about these incremental changes?

1. It should not be to hard to change the order in which a test’s name,
   the test’s output and the test result are printed?

   The current default is not too readable:

    tests/test_stuff.py::test_xy has this test PASSED OR FAILED PASSED

   In the example above, its quite hard to see that "has this test
   PASSED OR FAILED" is the tests output and not pytest-output.

   We could copy pytest-sugar's formatting to make it more readable:

    has this test PASSED OR FAILED
     tests/test_suff.py::test_xy PASSED

2. Since pytest already can color its output, we could color 
   the test dir and test file (in non-verbose mode) or test-path and
   test-func (in verbose mode) in different collors.

3. We could also show the progress in verbose mode.

4. We could colorize the dots and Fs of test results in non-verbose 
   mode (e.g., green ".", red "F", yellow "x", …)

5. Another idea would be to allow the user to provide templates for
   test output (similar to what you can to with hg/git log formatting)

These would be relatively small changes which don’t add any new
dependency or a lot of complexity to pytest but would improve the UX.


> Florian
> -- 
> https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
>   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
>         I love long mails! | https://email.is-not-s.ms/

More information about the testing-in-python mailing list