Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for tables with collapsing borders #2323

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/draw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def assert_different_renderings(name, *documents):

for i, pixels_1 in enumerate(pixels_list, start=1):
for j, pixels_2 in enumerate(pixels_list[i:], start=i+1):
if pixels_1 == pixels_2: # pragma: no cover
if tuple(pixels_1) == tuple(pixels_2): # pragma: no cover
name_1, name_2 = f'{name}_{i}', f'{name}_{j}'
write_png(name_1, pixels_1, width, height)
assert False, f'{name_1} and {name_2} are the same'
Expand Down
23 changes: 21 additions & 2 deletions tests/draw/test_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_borders(assert_pixels, assert_different_renderings, margin='10px',


@assert_no_logs
def test_borders_table_collapse(assert_pixels, assert_different_renderings):
def test_borders_table_collapse(assert_different_renderings):
"""Test the rendering of collapsing borders."""
source = '''
<style>
Expand All @@ -67,10 +67,29 @@ def test_borders_table_collapse(assert_pixels, assert_different_renderings):
source % border_style
for border_style in (
'none', 'solid', 'dashed', 'dotted', 'double',
'inset', 'outset', 'groove', 'ridge'))
'inset', 'groove'))
assert_different_renderings(*documents)


@assert_no_logs
@pytest.mark.parametrize('styles', (
('groove', 'outset'),
('ridge', 'inset'),
))
def test_borders_table_collapse_equivalent(assert_same_renderings, styles):
"""Test the rendering of equivalent collapsing borders."""
source = '''
<style>
@page { size: 140px 110px }
table { width: 100px; height: 70px; margin: 10px;
border-collapse: collapse; border: 10px %s blue }
</style>
<table><td>abc</td>'''

documents = (source % border_style for border_style in styles)
assert_same_renderings(*documents)


@assert_no_logs
def test_outlines(assert_pixels, assert_different_renderings):
return test_borders(
Expand Down
Loading