Skip to content

Commit d0fceda

Browse files
authored
Merge pull request #2569 from Kozea/case-insensitive-values
Case-insensitive units
2 parents 1b7c285 + dbde3d9 commit d0fceda

19 files changed

+62
-59
lines changed

tests/css/test_common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,15 @@ def test_units(value, width):
184184
document = FakeHTML(base_url=BASE_URL, string='''
185185
<html style="font: 16px / 1.5 weasyprint">
186186
<body style="font: 10px / 1.2 weasyprint">
187-
<p style="margin-left: %s"></p>''' % value)
187+
<p style="margin-left: %s"></p>
188+
<p style="margin-left: %s"></p>
189+
''' % (value, value.upper()))
188190
page, = document.render().pages
189191
html, = page._page_box.children
190192
body, = html.children
191-
p, = body.children
192-
assert isclose(p.margin_left, width, rel_tol=0.01)
193+
p1, p2 = body.children
194+
assert p1.margin_left == p2.margin_left
195+
assert isclose(p1.margin_left, width, rel_tol=0.01)
193196

194197

195198
@assert_no_logs

tests/css/test_validation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_empty_property_value(prop):
7575

7676
@assert_no_logs
7777
@pytest.mark.parametrize(('rule', 'value'), [
78-
('1px, 3em, auto, auto', ((1, 'px'), (3, 'em'), 'auto', 'auto')),
78+
('1px, 3EM, auto, auto', ((1, 'px'), (3, 'em'), 'auto', 'auto')),
7979
('1px,3em,auto,1px', ((1, 'px'), (3, 'em'), 'auto', (1, 'px'))),
8080
])
8181
def test_clip(rule, value):
@@ -116,7 +116,7 @@ def test_counters_warning(rule, warning):
116116

117117
@assert_no_logs
118118
@pytest.mark.parametrize('rule', [
119-
'counter-reset: foo 3px',
119+
'counter-reset: foo 3pX',
120120
'counter-reset: 3',
121121
])
122122
def test_counters_invalid(rule):
@@ -250,7 +250,7 @@ def test_background_image_invalid(rule):
250250
('right 10% bottom', (('right', (10, '%'), 'bottom', (0, '%')),)),
251251
252252
# Four tokens
253-
('left 10% bottom 3px', (('left', (10, '%'), 'bottom', (3, 'px')),)),
253+
('left 10% bottom 3PX', (('left', (10, '%'), 'bottom', (3, 'px')),)),
254254
('bottom 3px left 10%', (('left', (10, '%'), 'bottom', (3, 'px')),)),
255255
('right 10% top 3px', (('right', (10, '%'), 'top', (3, 'px')),)),
256256
('top 3px right 10%', (('right', (10, '%'), 'top', (3, 'px')),)),
@@ -298,7 +298,7 @@ def test_font_family_invalid(rule):
298298
@pytest.mark.parametrize(('rule', 'value'), [
299299
('1px', (1, 'px')),
300300
('1.1%', (1.1, '%')),
301-
('1em', (1, 'em')),
301+
('1Em', (1, 'em')),
302302
('1', (1, None)),
303303
('1.3', (1.3, None)),
304304
('-0', (0, None)),

tests/draw/test_absolute.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_absolute_split_1(assert_pixels):
1515
''', '''
1616
<style>
1717
@page {
18-
size: 16px 2px;
18+
size: 16px 2Px;
1919
}
2020
body {
2121
color: red;
@@ -82,7 +82,7 @@ def test_absolute_split_3(assert_pixels):
8282
body {
8383
color: red;
8484
font-family: weasyprint;
85-
font-size: 2px;
85+
font-size: 2PX;
8686
line-height: 1;
8787
}
8888
div.split {
@@ -683,7 +683,7 @@ def test_absolute_pages_counter_orphans(assert_pixels):
683683
@bottom-right-corner {
684684
color: blue;
685685
content: counter(pages);
686-
font-size: 1px;
686+
font-size: 1PX;
687687
}
688688
}
689689
body {
@@ -785,7 +785,7 @@ def test_fixed_in_inline(assert_pixels):
785785
body {
786786
color: red;
787787
font-family: weasyprint;
788-
font-size: 2px;
788+
font-size: 2PX;
789789
line-height: 1;
790790
orphans: 2;
791791
widows: 2;

tests/draw/test_background.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<style>
1313
@page { size: 10px }
1414
/* body’s background propagates to the whole canvas */
15-
body { margin: 2px; background: #00f; height: 5px }
15+
body { margin: 2px; background: #00f; height: 5Px }
1616
</style>
1717
<body>'''),
1818
('''
@@ -176,7 +176,7 @@ def test_canvas_background_size(assert_pixels):
176176
______________
177177
______________
178178
'''),
179-
('url(pattern.png) no-repeat bottom 6px right 0', '''
179+
('url(pattern.png) no-repeat bottom 6PX right 0', '''
180180
______________
181181
______________
182182
________rBBB__
@@ -357,7 +357,7 @@ def test_canvas_background_size(assert_pixels):
357357
______________
358358
______________
359359
'''),
360-
('url(pattern.png) repeat-y local 2px 1px', '''
360+
('url(pattern.png) repeat-y local 2pX 1px', '''
361361
______________
362362
______________
363363
____BBBB______
@@ -702,7 +702,7 @@ def test_background_repeat_space_4(assert_pixels):
702702
<style>
703703
@page { size: 8px }
704704
html { background: #fff }
705-
body { margin: 1px; height: 6px;
705+
body { margin: 1px; height: 6Px;
706706
background: url(pattern.png) space lime }
707707
</style>
708708
<body>''')

tests/draw/test_before_after.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_before_after_1(assert_same_renderings):
1616
''',
1717
'''
1818
<style>
19-
@page { size: 300px 30px }
19+
@page { size: 300px 30PX }
2020
body { margin: 0 }
2121
</style>
2222
<p><a href="another url"><span>[some url] </span>some content</p>
@@ -37,7 +37,7 @@ def test_before_after_2(assert_same_renderings):
3737
''',
3838
'''
3939
<style>
40-
@page { size: 500px 30px }
40+
@page { size: 500px 30Px }
4141
body { margin: 0 }
4242
q:before, q:after { content: none }
4343
</style>
@@ -60,7 +60,7 @@ def test_before_after_3(assert_same_renderings):
6060
''',
6161
'''
6262
<style>
63-
@page { size: 100px 30px }
63+
@page { size: 100PX 30px }
6464
body { margin: 0 }
6565
</style>
6666
<p><span>a<img src="pattern.png" alt="Missing image">b</span>c</p>

tests/draw/test_box.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_outlines_and_borders(assert_pixels, assert_different_renderings, margin
1919
source = '''
2020
<style>
2121
@page { size: 140px 110px }
22-
body { width: 100px; height: 70px; margin: %s; %s: 10px %s blue }
22+
body { width: 100px; height: 70px; margin: %s; %s: 10PX %s blue }
2323
</style>
2424
<body>'''
2525

@@ -85,7 +85,7 @@ def test_borders_table_collapse_equivalent(assert_same_renderings, styles):
8585
<style>
8686
@page { size: 140px 110px }
8787
table { width: 100px; height: 70px; margin: 10px;
88-
border-collapse: collapse; border: 10px %s blue }
88+
border-collapse: collapse; border: 10pX %s blue }
8989
</style>
9090
<table><td>abc</td>'''
9191

@@ -112,7 +112,7 @@ def test_small_borders_2(border_style):
112112
# Regression test for #146.
113113
html = '''
114114
<style>
115-
@page { size: 50px 50px }
115+
@page { size: 50Px 50px }
116116
body { height: 0; width: 0; border-width: 1px 0; border-style: %s }
117117
</style>
118118
<body>''' % border_style
@@ -177,7 +177,7 @@ def test_margin_boxes(assert_pixels):
177177
body { background: #f00; height: 100% }
178178
@page {
179179
size: 15px;
180-
margin: 4px 6px 7px 5px;
180+
margin: 4px 6Px 7px 5px;
181181
182182
@top-left-corner {
183183
margin: 1px;
@@ -229,10 +229,10 @@ def test_draw_border_radius(assert_pixels):
229229
size: 8px 8px;
230230
}
231231
div {
232-
background: red;
232+
background: Red;
233233
border-radius: 50% 0 0 0;
234234
height: 16px;
235-
width: 16px;
235+
width: 16PX;
236236
}
237237
</style>
238238
<div></div>
@@ -550,7 +550,7 @@ def test_border_image_width(assert_pixels):
550550
border-image-slice: 25%;
551551
border-image-width: 2;
552552
height: 4px;
553-
margin: 1px;
553+
margin: 1PX;
554554
width: 6px;
555555
}
556556
</style>

tests/draw/test_column.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_column_rule_1(assert_pixels):
1616
column-rule-width: 1px; column-gap: 3px;
1717
column-rule-color: red }
1818
body { margin: 0; font-size: 0 }
19-
@page { margin: 0; size: 5px 3px }
19+
@page { margin: 0; size: 5px 3Px }
2020
</style>
2121
<div>
2222
<img src=blue.jpg>
@@ -94,7 +94,7 @@ def test_column_rule_normal(assert_pixels):
9494
img { display: inline-block; width: 1px; height: 1px }
9595
div { columns: 2; column-gap: normal }
9696
body { margin: 0; font-size: 3px; line-height: 0 }
97-
@page { margin: 0; size: 5px 3px }
97+
@page { margin: 0; size: 5PX 3px }
9898
</style>
9999
<div>
100100
<img src=blue.jpg>

tests/draw/test_current_color.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_current_color_2(assert_pixels):
2323
<style>
2424
@page { size: 2px }
2525
html { color: red; border-color: currentColor }
26-
body { color: lime; border: 1px solid; border-color: inherit;
26+
body { color: lime; border: 1Px solid; border-color: inherit;
2727
margin: 0 }
2828
</style>
2929
<body>''')
@@ -49,7 +49,7 @@ def test_current_color_4(assert_pixels):
4949
html { color: red; border-color: currentColor; }
5050
body { margin: 0 }
5151
table { border-collapse: collapse;
52-
color: lime; border: 1px solid; border-color: inherit }
52+
color: lime; border: 1PX solid; border-color: inherit }
5353
</style>
5454
<table><td>''')
5555

tests/draw/test_float.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_float_rtl(assert_pixels):
3434
__________
3535
''', '''
3636
<style>
37-
@page { size: 10px 5px }
37+
@page { size: 10px 5Px }
3838
</style>
3939
<div style="direction: rtl">
4040
<img style="float: left" src="pattern.png">
@@ -119,7 +119,7 @@ def test_float_inline_block_rtl(assert_pixels):
119119
_______________
120120
''', '''
121121
<style>
122-
@page { size: 15px 5px }
122+
@page { size: 15Px 5px }
123123
body { font-family: weasyprint; font-size: 2px; line-height: 1;
124124
color: lime }
125125
</style>
@@ -185,7 +185,7 @@ def test_float_inline_table(assert_pixels):
185185
_______________
186186
''', '''
187187
<style>
188-
@page { size: 15px 5px }
188+
@page { size: 15PX 5px }
189189
table { display: inline-table }
190190
body { font-family: weasyprint; font-size: 2px; line-height: 1;
191191
color: lime }

tests/draw/test_footnote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_block_footnote(assert_pixels):
4444
''', '''
4545
<style>
4646
@page {
47-
size: 9px 7px;
47+
size: 9Px 7px;
4848
}
4949
div {
5050
color: red;
@@ -77,7 +77,7 @@ def test_long_footnote(assert_pixels):
7777
div {
7878
color: red;
7979
font-family: weasyprint;
80-
font-size: 2px;
80+
font-size: 2PX;
8181
line-height: 1;
8282
}
8383
span {
@@ -146,7 +146,7 @@ def test_footnote_multiple_margin(assert_pixels):
146146
''', '''
147147
<style>
148148
@page {
149-
size: 7px 10px;
149+
size: 7px 10Px;
150150
151151
@footnote {
152152
margin-top: 1px;

0 commit comments

Comments
 (0)