terminalwriter: improve `PYTEST_THEME`, `PYTEST_THEME_MODE` usage errors
This commit is contained in:
parent
67a570aea9
commit
7ef9da1f02
|
@ -235,13 +235,13 @@ class TerminalWriter:
|
||||||
|
|
||||||
except pygments.util.ClassNotFound as e:
|
except pygments.util.ClassNotFound as e:
|
||||||
raise UsageError(
|
raise UsageError(
|
||||||
f"PYTEST_THEME environment variable had an invalid value: '{theme}'. "
|
f"PYTEST_THEME environment variable has an invalid value: '{theme}'. "
|
||||||
"Only valid pygment styles are allowed."
|
"Hint: See available pygments styles with `pygmentize -L styles`."
|
||||||
) from e
|
) from e
|
||||||
except pygments.util.OptionError as e:
|
except pygments.util.OptionError as e:
|
||||||
raise UsageError(
|
raise UsageError(
|
||||||
f"PYTEST_THEME_MODE environment variable had an invalid value: '{theme_mode}'. "
|
f"PYTEST_THEME_MODE environment variable has an invalid value: '{theme_mode}'. "
|
||||||
"The only allowed values are 'dark' and 'light'."
|
"The allowed values are 'dark' (default) and 'light'."
|
||||||
) from e
|
) from e
|
||||||
|
|
||||||
def _highlight(
|
def _highlight(
|
||||||
|
|
|
@ -2609,8 +2609,8 @@ class TestCodeHighlight:
|
||||||
monkeypatch.setenv("PYTEST_THEME", "invalid")
|
monkeypatch.setenv("PYTEST_THEME", "invalid")
|
||||||
result = pytester.runpytest_subprocess("--color=yes")
|
result = pytester.runpytest_subprocess("--color=yes")
|
||||||
result.stderr.fnmatch_lines(
|
result.stderr.fnmatch_lines(
|
||||||
"ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. "
|
"ERROR: PYTEST_THEME environment variable has an invalid value: 'invalid'. "
|
||||||
"Only valid pygment styles are allowed."
|
"Hint: See available pygments styles with `pygmentize -L styles`."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_code_highlight_invalid_theme_mode(
|
def test_code_highlight_invalid_theme_mode(
|
||||||
|
@ -2625,8 +2625,8 @@ class TestCodeHighlight:
|
||||||
monkeypatch.setenv("PYTEST_THEME_MODE", "invalid")
|
monkeypatch.setenv("PYTEST_THEME_MODE", "invalid")
|
||||||
result = pytester.runpytest_subprocess("--color=yes")
|
result = pytester.runpytest_subprocess("--color=yes")
|
||||||
result.stderr.fnmatch_lines(
|
result.stderr.fnmatch_lines(
|
||||||
"ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. "
|
"ERROR: PYTEST_THEME_MODE environment variable has an invalid value: 'invalid'. "
|
||||||
"The only allowed values are 'dark' and 'light'."
|
"The allowed values are 'dark' (default) and 'light'."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue