Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Sep 15, 2024
1 parent b86fd65 commit 953f7d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
21 changes: 7 additions & 14 deletions tests/css/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,50 @@ def test_page():
}
''')])

page_type = PageType(
side='left', first=True, blank=False, index=0, name='')
page_type = PageType(side='left', first=True, blank=False, index=0, name=('', 2))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type)
assert style['margin_top'] == (5, 'px')
assert style['margin_left'] == (10, 'px')
assert style['margin_bottom'] == (10, 'px')
assert style['color'] == (1, 0, 0, 1) # red, inherited from html

page_type = PageType(
side='right', first=True, blank=False, index=0, name='')
page_type = PageType(side='right', first=True, blank=False, index=0, name=('', 1))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type)
assert style['margin_top'] == (5, 'px')
assert style['margin_left'] == (10, 'px')
assert style['margin_bottom'] == (16, 'px')
assert style['color'] == (0, 0, 1, 1) # blue

page_type = PageType(
side='left', first=False, blank=False, index=1, name='')
page_type = PageType(side='left', first=False, blank=False, index=1, name=('', 2))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type)
assert style['margin_top'] == (10, 'px')
assert style['margin_left'] == (10, 'px')
assert style['margin_bottom'] == (10, 'px')
assert style['color'] == (1, 0, 0, 1) # red, inherited from html

page_type = PageType(
side='right', first=False, blank=False, index=1, name='')
page_type = PageType(side='right', first=False, blank=False, index=1, name=('', 1))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type)
assert style['margin_top'] == (10, 'px')
assert style['margin_left'] == (10, 'px')
assert style['margin_bottom'] == (16, 'px')
assert style['color'] == (0, 0, 1, 1) # blue

page_type = PageType(
side='left', first=True, blank=False, index=0, name='')
page_type = PageType(side='left', first=True, blank=False, index=0, name=('', 2))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type, '@top-left')
assert style is None

page_type = PageType(
side='right', first=True, blank=False, index=0, name='')
page_type = PageType(side='right', first=True, blank=False, index=0, name=('', 1))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type, '@top-left')
assert style['font_size'] == 20 # inherited from @page
assert style['width'] == (200, 'px')

page_type = PageType(
side='right', first=True, blank=False, index=0, name='')
page_type = PageType(side='right', first=True, blank=False, index=0, name=('', 1))
set_page_type_computed_styles(page_type, document, style_for)
style = style_for(page_type, '@top-right')
assert style['font_size'] == 10
Expand Down
17 changes: 10 additions & 7 deletions tests/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,21 @@ def test_whitespace():

@assert_no_logs
@pytest.mark.parametrize('page_type, top, right, bottom, left', (
(PageType(side='left', first=True, index=0, blank=None, name=None),
(PageType(side='left', first=True, index=0, blank=None, name=('', 0)),
20, 3, 3, 10),
(PageType(side='right', first=True, index=0, blank=None, name=None),
(PageType(side='right', first=True, index=0, blank=None, name=('', 0)),
20, 10, 3, 3),
(PageType(side='left', first=None, index=1, blank=None, name=None),
(PageType(side='left', first=None, index=1, blank=None, name=('', 1)),
10, 3, 3, 10),
(PageType(side='right', first=None, index=1, blank=None, name=None),
(PageType(side='right', first=None, index=1, blank=None, name=('', 1)),
10, 10, 3, 3),
(PageType(side='right', first=None, index=1, blank=None, name='name'),
(PageType(side='right', first=None, index=1, blank=None, name=('name', 0)),
5, 10, 3, 15),
(PageType(side='right', first=None, index=2, blank=None, name='name'),
(PageType(side='right', first=None, index=1, blank=None, name=('name', 1)),
5, 10, 4, 15),
(PageType(side='right', first=None, index=2, blank=None, name=('name', 0)),
5, 10, 1, 15),
(PageType(side='right', first=None, index=8, blank=None, name='name'),
(PageType(side='right', first=None, index=8, blank=None, name=('name', 8)),
5, 10, 2, 15),
))
def test_page_style(page_type, top, right, bottom, left):
Expand All @@ -270,6 +272,7 @@ def test_page_style(page_type, top, right, bottom, left):
@page name { margin-left: 15px; margin-top: 5px }
@page :nth(3) { margin-bottom: 1px }
@page :nth(5n+4) { margin-bottom: 2px }
@page :nth(2 of name) { margin-bottom: 4px }
@page :first { margin-top: 20px }
@page :right { margin-right: 10px; margin-top: 10px }
@page :left { margin-left: 10px; margin-top: 10px }
Expand Down

0 comments on commit 953f7d6

Please sign in to comment.