failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · Textualize/rich
fix(panel): fix title missing panel background
Fix `Panel` title missing the panel background style.
This really just reverts the change in 7a38204. There's a history of issues related to the panel title styles, so I was careful to run all the examples in those issues to ensure there wasn't any regression.
Fixes #3569
## Type of changes
- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other
## Checklist
- [x] I've run the latest [black](https://github.com/psf/black) with default args on new code.
- [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [x] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
............F
=================================== FAILURES ===================================
____________________ test_title_text_with_panel_background _____________________
def test_title_text_with_panel_background() -> None:
"""Regression test for https://github.com/Textualize/rich/issues/3569"""
panel = Panel(
"Hello, World",
style="on 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[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"
> assert result == expected
E AssertionError: assert '\x1b[44m╭─\x...4m─╯\x1b[0m\n' == '\x1b[44m╭─\x...4m─╯\x1b[0m\n'
E
E Skipping 33 identical leading characters in diff, use -v to show
E - ──[0m[31;44m title [0m[44m────────────────────[0m[44m─╮[0m
E ? ---
E + ──[0m[31m title [0m[44m────────────────────[0m[44m─╮[0m
E [44m│[0m[44m [0m[44mHello, World[0m[44m [0m[44m [0m[44m│[0m
E - [44m╰─[0m[44m──────────────────[0m[1;35;44m subtitle [0m[44m──────────────────[0m[44m─╯[0m
E ? ---
E + [44m╰─[0m[44m──────────────────[0m[1;35m subtitle [0m[44m──────────────────[0m[44m─╯[0m
tests/test_panel.py:172: AssertionError
----------------------------- Captured stdout call -----------------------------
'\x1b[44m╭─\x1b[0m\x1b[44m───────────────────\x1b[0m\x1b[31m 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;35m subtitle \x1b[0m\x1b[44m──────────────────\x1b[0m\x1b[44m─╯\x1b[0m\n'
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 12 passed in 0.12s