[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-05-13 06:30:00 +00:00
parent 98121455e5
commit fa32525f4c
2 changed files with 13 additions and 9 deletions

View File

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

View File

@ -219,20 +219,24 @@ class TerminalWriter:
else:
try:
# Import new more rich color formatters from the pygments library
from pygments.formatters.terminal256 import TerminalTrueColorFormatter
from pygments.formatters.terminal256 import Terminal256Formatter
from pygments.formatters.terminal256 import TerminalTrueColorFormatter
# Use terminal formatters depending on user environment variables
if os.environ.get('COLORTERM','') in ('truecolor', '24bit'):
if os.environ.get("COLORTERM", "") in ("truecolor", "24bit"):
# Style determined by user set environment variable, if none then use default style
terminal_formatter = TerminalTrueColorFormatter(style=os.getenv("PYTEST_THEME","default"))
elif '256' in os.environ.get('TERM', ''):
terminal_formatter = Terminal256Formatter(style=os.getenv("PYTEST_THEME","default"))
terminal_formatter = TerminalTrueColorFormatter(
style=os.getenv("PYTEST_THEME", "default")
)
elif "256" in os.environ.get("TERM", ""):
terminal_formatter = Terminal256Formatter(
style=os.getenv("PYTEST_THEME", "default")
)
else:
terminal_formatter = TerminalFormatter(
bg=os.getenv("PYTEST_THEME_MODE", "dark"),
style=os.getenv("PYTEST_THEME"),
)
bg=os.getenv("PYTEST_THEME_MODE", "dark"),
style=os.getenv("PYTEST_THEME"),
)
highlighted: str = highlight(
source,
Lexer(),