MCPcopy
hub / github.com/Textualize/rich / test_traceback_console_theme_applies

Function test_traceback_console_theme_applies

tests/test_traceback.py:213–233  ·  view source on GitHub ↗

Ensure that themes supplied via Console init work on Tracebacks. Regression test for https://github.com/Textualize/rich/issues/1786

()

Source from the content-addressed store, hash-verified

211
212@pytest.mark.skipif(sys.platform == "win32", reason="renders different on windows")
213def test_traceback_console_theme_applies():
214 """
215 Ensure that themes supplied via Console init work on Tracebacks.
216 Regression test for https://github.com/Textualize/rich/issues/1786
217 """
218 r, g, b = 123, 234, 123
219 console = Console(
220 force_terminal=True,
221 _environ={"COLORTERM": "truecolor"},
222 theme=Theme({"traceback.title": f"rgb({r},{g},{b})"}),
223 )
224
225 console.begin_capture()
226 try:
227 1 / 0
228 except Exception:
229 console.print_exception()
230
231 result = console.end_capture()
232
233 assert f"\\x1b[38;2;{r};{g};{b}mTraceback \\x1b[0m" in repr(result)
234
235
236def test_broken_str():

Callers

nothing calls this directly

Calls 5

begin_captureMethod · 0.95
print_exceptionMethod · 0.95
end_captureMethod · 0.95
ConsoleClass · 0.90
ThemeClass · 0.90

Tested by

no test coverage detected