terminalwriter: improve `PYTEST_THEME`, `PYTEST_THEME_MODE` usage errors

This commit is contained in:
Ran Benita 2024-06-10 11:41:10 +03:00
parent 67a570aea9
commit 7ef9da1f02
2 changed files with 8 additions and 8 deletions

View File

@ -235,13 +235,13 @@ class TerminalWriter:
except pygments.util.ClassNotFound as e:
raise UsageError(
f"PYTEST_THEME environment variable had an invalid value: '{theme}'. "
"Only valid pygment styles are allowed."
f"PYTEST_THEME environment variable has an invalid value: '{theme}'. "
"Hint: See available pygments styles with `pygmentize -L styles`."
) from e
except pygments.util.OptionError as e:
raise UsageError(
f"PYTEST_THEME_MODE environment variable had an invalid value: '{theme_mode}'. "
"The only allowed values are 'dark' and 'light'."
f"PYTEST_THEME_MODE environment variable has an invalid value: '{theme_mode}'. "
"The allowed values are 'dark' (default) and 'light'."
) from e
def _highlight(

View File

@ -2609,8 +2609,8 @@ class TestCodeHighlight:
monkeypatch.setenv("PYTEST_THEME", "invalid")
result = pytester.runpytest_subprocess("--color=yes")
result.stderr.fnmatch_lines(
"ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. "
"Only valid pygment styles are allowed."
"ERROR: PYTEST_THEME environment variable has an invalid value: 'invalid'. "
"Hint: See available pygments styles with `pygmentize -L styles`."
)
def test_code_highlight_invalid_theme_mode(
@ -2625,8 +2625,8 @@ class TestCodeHighlight:
monkeypatch.setenv("PYTEST_THEME_MODE", "invalid")
result = pytester.runpytest_subprocess("--color=yes")
result.stderr.fnmatch_lines(
"ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. "
"The only allowed values are 'dark' and 'light'."
"ERROR: PYTEST_THEME_MODE environment variable has an invalid value: 'invalid'. "
"The allowed values are 'dark' (default) and 'light'."
)