Skip to content

Examples on Pytest.org should be in color #4430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
goodside opened this issue Nov 21, 2018 · 11 comments
Closed

Examples on Pytest.org should be in color #4430

goodside opened this issue Nov 21, 2018 · 11 comments
Labels
type: docs documentation improvement, missing or needing clarification

Comments

@goodside
Copy link

goodside commented Nov 21, 2018

I write all my tests in unittest (I like classes and disagree with some of pytest's design decisions, like #3834) but I always install pytest on every box I use. Why? Colors.

Anyone who's been forced to python -m unittest knows how illegible it is without the red/green headers and highlights. I go out of my way to keep compatibility with both unittest and pytest (e.g., no self.subTest()) just to get color output. New users install pytest for the assert, but they stay for the colors.

I'd suggest it's uniquely important that the giant, above-the-fold example output on the pytest.org landing page not be in black-and-white. Colorizing other examples in the docs could also improve readability.

Sphinx has a contrib module for parsing ANSI color codes from pytest output that should work.

@RonnyPfannschmidt
Copy link
Member

the outputs are scm tracked atm - so having/storing the output currently is potentially problematic

we ought to take a look at a solution

@nicoddemus nicoddemus added the type: docs documentation improvement, missing or needing clarification label Nov 21, 2018
@asottile
Copy link
Member

I wonder if we could make a custom highlighter to ~mostly get this working nicely

@nicoddemus
Copy link
Member

About the landing page, I agree that's probably a good idea to have that in color. A quick solution is to change that output in the landing page to a picture. What do you folks think?

@asottile
Copy link
Member

I might hack on writing a pygments-pytest (pytest-pygments?) -- don't hold your breath though 😆

@nicoddemus
Copy link
Member

I might hack on writing a pygments-pytest (pytest-pygments?) -- don't hold your breath though

That would be an honorable endeavor, I don't doubt! 😁

Meanwhile a picture in the landing page might fit the bill hehehe

@asottile
Copy link
Member

ooh! this doesn't actually look that difficult to get ~something going -- it's going to inevitably drift from pytest but I figure it'll be better than nothing. I'm inspired -- I might hack on this on stream tonight 😆

Will probably use @chriskuehl's excellent pygments-ansi-color as an example. The rest of the docs for writing a lexer are here. Might try and make one for pre-commit first since that'll be simpler

@asottile
Copy link
Member

I mostly got it working! https://github.com/asottile/pygments-pytest (hard to tell from the README -- I'll make it more obvious soon!)

I need to polish up the README, write some tests, and handle a few edgecases and/or make pytest's output more consistent in a few cases

@RonnyPfannschmidt
Copy link
Member

@asottile well done, it looks way better than my original approach from 2012 which failed

@RonnyPfannschmidt
Copy link
Member

im also totally for making output more consistent

@Zac-HD
Copy link
Member

Zac-HD commented Dec 5, 2018

Closed by #4456 🎉

@Zac-HD Zac-HD closed this as completed Dec 5, 2018
@asottile
Copy link
Member

asottile commented Dec 5, 2018

This was one of the most fun things I've done in a while btw, thanks for the idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs documentation improvement, missing or needing clarification
Projects
None yet
Development

No branches or pull requests

5 participants