failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · Textualize/rich
fix table rendering order of box elements
## Type of changes
- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [x] 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.
## Description
* Previously "mid" box elements appeared in last line of table (footer), while "footer" box elements appeared mid table body. Reversed that order so mid is truly mid, footer is truly footer.
* Tested with:
```
table.box.head_left = '1'
table.box.head_vertical = '2'
table.box.head_right = '3'
table.box.mid_left = '4'
table.box.mid_vertical = '5'
table.box.mid_right = '6'
table.box.foot_left = '7'
table.box.foot_vertical = '8'
table.box.foot_right = '9'
```
After change, correct ordering:
```
+--------------------------------------------------------------------------+
1Date 2Title 2 Production2 Box Office3
|------------ --------------------------------- ------------ --------------|
4Dec 20, 20195Star Wars: The Rise of Skywalker 5$275,000,0005 $375,126,1186
4May 25, 20185Solo: A Star Wars Story 5$275,000,0005 $393,151,3476
7Dec 15, 20178Star Wars Ep. VIII: The Last Jedi8$262,000,0008$1,332,539,8899
+--------------------------------------------------------------------------+
```
* All non-skipped prior automated tests pass. No automated tests added. Unclear that additional test for box ordering would add proportionate value.
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
...............F
=================================== FAILURES ===================================
_ test_placement_table_box_elements[False-False-abbbbbcbbbbbbbbbcbbbbcbbbbbd\n1Dec 2Skywalker2275M2375M 3\n4May 5Solo 5275M5393M 6\nijjjjjkjjjjjjjjjkjjjjkjjjjjl\n7Dec 8Last Jedi8262M81333M9\nqrrrrrsrrrrrrrrrsrrrrsrrrrrt\n] _
show_header = False, show_footer = False
expected = 'abbbbbcbbbbbbbbbcbbbbcbbbbbd\n1Dec 2Skywalker2275M2375M 3\n4May 5Solo 5275M5393M 6\nijjjjjkjjjjjjjjjkjjjjkjjjjjl\n7Dec 8Last Jedi8262M81333M9\nqrrrrrsrrrrrrrrrsrrrrsrrrrrt\n'
@pytest.mark.parametrize(
"show_header,show_footer,expected",
[
(
False,
False,
dedent(
"""
abbbbbcbbbbbbbbbcbbbbcbbbbbd
1Dec 2Skywalker2275M2375M 3
4May 5Solo 5275M5393M 6
ijjjjjkjjjjjjjjjkjjjjkjjjjjl
7Dec 8Last Jedi8262M81333M9
qrrrrrsrrrrrrrrrsrrrrsrrrrrt
"""
).lstrip(),
),
(
True,
False,
dedent(
"""
abbbbbcbbbbbbbbbcbbbbcbbbbbd
1Month2Nickname 2Cost2Gross3
efffffgfffffffffgffffgfffffh
4Dec 5Skywalker5275M5375M 6
4May 5Solo 5275M5393M 6
ijjjjjkjjjjjjjjjkjjjjkjjjjjl
7Dec 8Last Jedi8262M81333M9
qrrrrrsrrrrrrrrrsrrrrsrrrrrt
"""
).lstrip(),
),
(
False,
True,
dedent(
"""
abbbbbcbbbbbbbbbcbbbbcbbbbbd
1Dec 2Skywalker2275M2375M 3
4May 5Solo 5275M5393M 6
ijjjjjkjjjjjjjjjkjjjjkjjjjjl
4Dec 5Last Jedi5262M51333M6
mnnnnnonnnnnnnnnonnnnonnnnnp
7MONTH8NICKNAME 8COST8GROSS9
qrrrrrsrrrrrrrrrsrrrrsrrrrrt
"""
).lstrip(),
),
(
True,
True,
dedent(
"""
abbbbbcbbbbbbbbbcbbbbcbbbbbd
1Month2Nickname 2Cost2Gross3
efffffgfffffffffgffffgfffffh
4Dec 5Skywalker5275M5375M 6
4May 5Solo 5275M5393M 6
ijjjjjkjjjjjjjjjkjjjjkjjjjjl
4Dec 5Last Jedi5262M51333M6
mnnnnnonnnnnnnnnonnnnonnnnnp
7MONTH8NICKNAME 8COST8GROSS9
qrrrrrsrrrrrrrrrsrrrrsrrrrrt
"""
).lstrip(),
),
],
)
def test_placement_table_box_elements(show_header, show_footer, expected):
"""Ensure box drawing characters correctly positioned."""
table = Table(
box=box.ASCII, show_header=show_header, show_footer=show_footer, padding=0
)
# content rows indicated by numerals, pure dividers by letters
table.box.__dict__.update(
top_left="a",
top="b",
top_divider="c",
top_right="d",
head_left="1",
head_vertical="2",
head_right="3",
head_row_left="e",
head_row_horizontal="f",
head_row_cross="g",
head_row_right="h",
mid_left="4",
mid_vertical="5",
mid_right="6",
row_left="i",
row_horizontal="j",
row_cross="k",
row_right="l",
foot_left="7",
foot_vertical="8",
foot_right="9",
foot_row_left="m",
foot_row_horizontal="n",
foot_row_cross="o",
foot_row_right="p",
bottom_left="q",
bottom="r",
bottom_divider="s",
bottom_right="t",
)
# add content - note headers title case, footers upper case
table.add_column("Month", "MONTH", width=5)
table.add_column("Nickname", "NICKNAME", width=9)
table.add_column("Cost", "COST", width=4)
table.add_column("Gross", "GROSS", width=5)
table.add_row("Dec", "Skywalker", "275M", "375M")
table.add_row("May", "Solo", "275M", "393M")
table.add_section()
table.add_row("Dec", "Last Jedi", "262M", "1333M")
console = Console(record=True, width=28)
console.print(table)
output = console.export_text()
print(repr(output))
> assert output == expected
E AssertionError: assert 'abbbbbcbbbbb...rrrrsrrrrrt\n' == 'abbbbbcbbbbb...rrrrsrrrrrt\n'
E
E Skipping 48 identical leading characters in diff, use -v to show
E 5M2375M 3
E - 4May 5Solo 5275M5393M 6
E ? ^ ^ ^ ^ ^
E + 7May 8Solo 8275M8393M 9
E ? ^ ^ ^ ^ ^...
E
E ...Full output truncated (6 lines hidden), use '-vv' to show
tests/test_table.py:363: AssertionError
----------------------------- Captured stdout call -----------------------------
abbbbbcbbbbbbbbbcbbbbcbbbbbd
1Dec 2Skywalker2275M2375M 3
7May 8Solo 8275M8393M 9
ijjjjjkjjjjjjjjjkjjjjkjjjjjl
4Dec 5Last Jedi5262M51333M6
qrrrrrsrrrrrrrrrsrrrrsrrrrrt
'abbbbbcbbbbbbbbbcbbbbcbbbbbd\n1Dec 2Skywalker2275M2375M 3\n7May 8Solo 8275M8393M 9\nijjjjjkjjjjjjjjjkjjjjkjjjjjl\n4Dec 5Last Jedi5262M51333M6\nqrrrrrsrrrrrrrrrsrrrrsrrrrrt\n'
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 15 passed in 0.14s