Skip to content
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

Add "TerminalWriter.write_source" to write highlighted source code #241

Closed
wants to merge 1 commit into from

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Feb 2, 2020

How this looks like in pytest:

image

Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I've thought about adding it to pytest myself.
I think given how thin the wrapper is there is not much gain in adding to pylib - it should rather go into pytest directly AFAICS.
(there's the base for extending it in _pytest._io already.

"""Writes the given source code highlighted"""
if self.hasmarkup:
try:
from pygments.formatters.terminal import TerminalFormatter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also 256-color and true color support.. https://github.com/pygments/pygments/blob/master/pygments/formatters/terminal256.py

Something like this could be used for auto-detect, but it should be made configurable probably.

        pygments_formatter_class = "pygments.formatters.TerminalTrueColorFormatter"
        pygments_formatter_kwargs = {"bg": "light", "style": "solarized-light"}

(from my pdbpp config)

@nicoddemus
Copy link
Member Author

Closing in favor of pytest-dev/pytest#6658

@nicoddemus nicoddemus closed this Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants