[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
3acc7e417c
commit
d393c54822
|
@ -2,4 +2,4 @@ Improved the terminal writer to be able to use Terminal256Formatter and Terminal
|
||||||
|
|
||||||
These are newer versions of TerminalFormmater from the pygments library that is currently in use.
|
These are newer versions of TerminalFormmater from the pygments library that is currently in use.
|
||||||
|
|
||||||
These style of these formatters are set by the users through the environmental variable PYTEST_THEME.
|
These style of these formatters are set by the users through the environmental variable PYTEST_THEME.
|
||||||
|
|
|
@ -194,9 +194,8 @@ class TerminalWriter:
|
||||||
for indent, new_line in zip(indents, new_lines):
|
for indent, new_line in zip(indents, new_lines):
|
||||||
self.line(indent + new_line)
|
self.line(indent + new_line)
|
||||||
|
|
||||||
def _highlight(
|
|
||||||
self, source: str, lexer: Literal["diff", "python"] = "python"
|
def _highlight(self, source: str, lexer: Literal["diff", "python"] = "python") -> str:
|
||||||
) -> str:
|
|
||||||
"""Highlight the given source if we have markup support."""
|
"""Highlight the given source if we have markup support."""
|
||||||
from _pytest.config.exceptions import UsageError
|
from _pytest.config.exceptions import UsageError
|
||||||
|
|
||||||
|
@ -219,14 +218,22 @@ def _highlight(
|
||||||
# Terminal set to newer pygment formatters depending on user environment variables
|
# Terminal set to newer pygment formatters depending on user environment variables
|
||||||
if os.getenv("COLORTERM", "") in ("truecolor", "24bit"):
|
if os.getenv("COLORTERM", "") in ("truecolor", "24bit"):
|
||||||
from pygments.formatters.terminal256 import TerminalTrueColorFormatter
|
from pygments.formatters.terminal256 import TerminalTrueColorFormatter
|
||||||
terminal_formatter = TerminalTrueColorFormatter(style=os.getenv("PYTEST_THEME", "default"))
|
|
||||||
|
terminal_formatter = TerminalTrueColorFormatter(
|
||||||
|
style=os.getenv("PYTEST_THEME", "default")
|
||||||
|
)
|
||||||
elif "256" in os.getenv("TERM", ""):
|
elif "256" in os.getenv("TERM", ""):
|
||||||
from pygments.formatters.terminal256 import Terminal256Formatter
|
from pygments.formatters.terminal256 import Terminal256Formatter
|
||||||
terminal_formatter = Terminal256Formatter(style=os.getenv("PYTEST_THEME", "default"))
|
|
||||||
|
terminal_formatter = Terminal256Formatter(
|
||||||
|
style=os.getenv("PYTEST_THEME", "default")
|
||||||
|
)
|
||||||
# Otherwise use the terminal formatter used previously
|
# Otherwise use the terminal formatter used previously
|
||||||
else:
|
else:
|
||||||
terminal_formatter = TerminalFormatter(bg=os.getenv("PYTEST_THEME_MODE", "dark"),
|
terminal_formatter = TerminalFormatter(
|
||||||
style=os.getenv("PYTEST_THEME", "default"))
|
bg=os.getenv("PYTEST_THEME_MODE", "dark"),
|
||||||
|
style=os.getenv("PYTEST_THEME", "default"),
|
||||||
|
)
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return source
|
return source
|
||||||
|
|
Loading…
Reference in New Issue