[TIP] pytest-sugar -> pytest

Florian Bruhin me at the-compiler.org
Fri Sep 21 05:14:31 PDT 2018


On Wed, Sep 19, 2018 at 12:22:59PM +0200, Stefan Scherfke wrote:
> 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

I wonder how feasible that is (with the test output) without having to
capture output. Not sure why this difference even occurs - does
pytest-sugar only print the test name after the test has finished?
If so, that might introduce a new UI issue: You don't clearly see which
test is running right now.

> 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.

That seems like a nice idea!

Note that some colors won't work well depending on the background color,
but what about making it bold?

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

That already is the case here, with pytest 3.6.4.

(I'd like to upgrade to 3.8, but
https://github.com/pytest-dev/pytest-bdd/issues/250 prevents me from
doing so - anyways, different story :D)

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

I'd probably keep the dots in the default color, especially if the test
names and all that is already colored. Pointing out the (hopefully) less often
printed chars seems nice though.

> 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)

Not sure how much you can cram into a template string. At some point
it's just easier to write code and write a plugin.

My $0.02 ;-)

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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20180921/faaa2ec3/attachment.pgp>


More information about the testing-in-python mailing list