From 953f7d63c61ca48c29c281b2465b3493e1a96332 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 13 Sep 2024 05:36:46 +0200 Subject: [PATCH] Fix tests --- tests/css/test_pages.py | 21 +++++++-------------- tests/test_boxes.py | 17 ++++++++++------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/css/test_pages.py b/tests/css/test_pages.py index 114dd575c..c4df8f49d 100644 --- a/tests/css/test_pages.py +++ b/tests/css/test_pages.py @@ -26,8 +26,7 @@ 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') @@ -35,8 +34,7 @@ def test_page(): 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') @@ -44,8 +42,7 @@ def test_page(): 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') @@ -53,8 +50,7 @@ def test_page(): 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') @@ -62,21 +58,18 @@ def test_page(): 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 diff --git a/tests/test_boxes.py b/tests/test_boxes.py index 566748068..4818994fe 100644 --- a/tests/test_boxes.py +++ b/tests/test_boxes.py @@ -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): @@ -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 }