Skip to content

Commit

Permalink
Merge pull request Kozea#2323 from Kozea/border-collapse
Browse files Browse the repository at this point in the history
Fix tests for tables with collapsing borders
  • Loading branch information
liZe authored Dec 7, 2024
2 parents 8d24a10 + 975a8b4 commit 003ff42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
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

0 comments on commit 003ff42

Please sign in to comment.