Skip to content

Commit

Permalink
test: test flex-dimension column for issue Kozea#2222
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Aug 18, 2024
1 parent e8ef883 commit 0217f38
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/layout/test_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,65 @@ def test_flex_absolute_content():
assert h1.position_y == 0
assert p.position_x == 0
assert p.position_y == 0


@assert_no_logs
def test_flex_column_height():
# Regression test for https://github.com/Kozea/WeasyPrint/issues/2222
page, = render_pages("""
<section style="display: flex; width: 300px">
<article style="display: flex; flex-direction: column" id="a1">
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</article>
<article style="display: flex; flex-direction: column" id="a2">
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</article>
</section>
""")
html, = page.children
body, = html.children
section, = body.children
a1, a2 = section.children
assert a1.height == section.height
assert a2.height == section.height


@assert_no_logs
def test_flex_column_height2():
# Another regression test for
# https://github.com/Kozea/WeasyPrint/issues/2222
page, = render_pages("""
<section style="display: flex; flex-direction: column; width: 300px">
<article style="margin: 5px" id="a1">
Question 1? With quite a lot of extra text,
which should not overflow in the PDF, we hope.
</article>
<article style="margin: 5px" id="a2">
Answer 1. With quite a lot of extra text,
which should not overflow in the PDF, we hope?
</article>
</section>
""")
html, = page.children
body, = html.children
section, = body.children
a1, a2 = section.children
assert section.height == (a1.height + a2.height
+ a1.margin_top + a1.margin_bottom
+ a2.margin_top + a2.margin_bottom)

0 comments on commit 0217f38

Please sign in to comment.