Skip to content

Commit 7ef9da1

Browse files
committed
terminalwriter: improve PYTEST_THEME, PYTEST_THEME_MODE usage errors
1 parent 67a570a commit 7ef9da1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/_pytest/_io/terminalwriter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ def _get_pygments_formatter(self) -> Optional["Formatter"]:
235235

236236
except pygments.util.ClassNotFound as e:
237237
raise UsageError(
238-
f"PYTEST_THEME environment variable had an invalid value: '{theme}'. "
239-
"Only valid pygment styles are allowed."
238+
f"PYTEST_THEME environment variable has an invalid value: '{theme}'. "
239+
"Hint: See available pygments styles with `pygmentize -L styles`."
240240
) from e
241241
except pygments.util.OptionError as e:
242242
raise UsageError(
243-
f"PYTEST_THEME_MODE environment variable had an invalid value: '{theme_mode}'. "
244-
"The only allowed values are 'dark' and 'light'."
243+
f"PYTEST_THEME_MODE environment variable has an invalid value: '{theme_mode}'. "
244+
"The allowed values are 'dark' (default) and 'light'."
245245
) from e
246246

247247
def _highlight(

testing/test_terminal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,8 +2609,8 @@ def test_foo():
26092609
monkeypatch.setenv("PYTEST_THEME", "invalid")
26102610
result = pytester.runpytest_subprocess("--color=yes")
26112611
result.stderr.fnmatch_lines(
2612-
"ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. "
2613-
"Only valid pygment styles are allowed."
2612+
"ERROR: PYTEST_THEME environment variable has an invalid value: 'invalid'. "
2613+
"Hint: See available pygments styles with `pygmentize -L styles`."
26142614
)
26152615

26162616
def test_code_highlight_invalid_theme_mode(
@@ -2625,8 +2625,8 @@ def test_foo():
26252625
monkeypatch.setenv("PYTEST_THEME_MODE", "invalid")
26262626
result = pytester.runpytest_subprocess("--color=yes")
26272627
result.stderr.fnmatch_lines(
2628-
"ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. "
2629-
"The only allowed values are 'dark' and 'light'."
2628+
"ERROR: PYTEST_THEME_MODE environment variable has an invalid value: 'invalid'. "
2629+
"The allowed values are 'dark' (default) and 'light'."
26302630
)
26312631

26322632

0 commit comments

Comments
 (0)