Ensure that themes supplied via Console init work on Tracebacks. Regression test for https://github.com/Textualize/rich/issues/1786
()
| 211 | |
| 212 | @pytest.mark.skipif(sys.platform == "win32", reason="renders different on windows") |
| 213 | def 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 | |
| 236 | def test_broken_str(): |
nothing calls this directly
no test coverage detected