test(panel): add regression test for title with border color

It looks like there's a history of issues related to the panel border
style, so add a test to prevent any regressions.
This commit is contained in:
TomJGooding 2025-05-01 21:12:00 +01:00
parent 0c6c75644f
commit 69e1618f1f

View file

@ -124,6 +124,30 @@ def test_title_text() -> None:
assert result == expected
def test_title_text_with_border_color() -> None:
"""Regression test for https://github.com/Textualize/rich/issues/2745"""
panel = Panel(
"Hello, World",
border_style="blue",
title=Text("title", style="red"),
subtitle=Text("subtitle", style="magenta bold"),
)
console = Console(
file=io.StringIO(),
width=50,
height=20,
legacy_windows=False,
force_terminal=True,
color_system="truecolor",
)
console.print(panel)
result = console.file.getvalue()
print(repr(result))
expected = "\x1b[34m╭─\x1b[0m\x1b[34m───────────────────\x1b[0m\x1b[31m title \x1b[0m\x1b[34m────────────────────\x1b[0m\x1b[34m─╮\x1b[0m\n\x1b[34m│\x1b[0m Hello, World \x1b[34m│\x1b[0m\n\x1b[34m╰─\x1b[0m\x1b[34m──────────────────\x1b[0m\x1b[1;35m subtitle \x1b[0m\x1b[34m──────────────────\x1b[0m\x1b[34m─╯\x1b[0m\n"
assert result == expected
if __name__ == "__main__":
expected = []
for panel in tests: