Regression test for https://github.com/Textualize/rich/issues/3569
()
| 149 | |
| 150 | |
| 151 | def test_title_text_with_panel_background() -> None: |
| 152 | """Regression test for https://github.com/Textualize/rich/issues/3569""" |
| 153 | panel = Panel( |
| 154 | "Hello, World", |
| 155 | style="on blue", |
| 156 | title=Text("title", style="red"), |
| 157 | subtitle=Text("subtitle", style="magenta bold"), |
| 158 | ) |
| 159 | console = Console( |
| 160 | file=io.StringIO(), |
| 161 | width=50, |
| 162 | height=20, |
| 163 | legacy_windows=False, |
| 164 | force_terminal=True, |
| 165 | color_system="truecolor", |
| 166 | ) |
| 167 | console.print(panel) |
| 168 | |
| 169 | result = console.file.getvalue() |
| 170 | print(repr(result)) |
| 171 | expected = "\x1b[44m╭─\x1b[0m\x1b[44m───────────────────\x1b[0m\x1b[31;44m title \x1b[0m\x1b[44m────────────────────\x1b[0m\x1b[44m─╮\x1b[0m\n\x1b[44m│\x1b[0m\x1b[44m \x1b[0m\x1b[44mHello, World\x1b[0m\x1b[44m \x1b[0m\x1b[44m \x1b[0m\x1b[44m│\x1b[0m\n\x1b[44m╰─\x1b[0m\x1b[44m──────────────────\x1b[0m\x1b[1;35;44m subtitle \x1b[0m\x1b[44m──────────────────\x1b[0m\x1b[44m─╯\x1b[0m\n" |
| 172 | assert result == expected |
| 173 | |
| 174 | |
| 175 | if __name__ == "__main__": |