@@ -38,7 +38,7 @@ def test_css_parse_comments():
38
38
markers like !important, but we should
39
39
ignore them in the future''' )
40
40
def test_css_parse_specificity ():
41
- pass # TODO
41
+ assert_same_resolution ( 'font-weight: bold' , 'font-weight: bold !important' )
42
42
43
43
44
44
@pytest .mark .xfail (reason = 'Splitting CSS declarations not yet sensitive to '
@@ -51,8 +51,36 @@ def test_css_parse_strings():
51
51
{'background-image' : 'url("http://blah.com/foo?a;b=c")' })
52
52
53
53
54
- def test_css_parse_invalid ():
55
- pass # TODO
54
+ @pytest .mark .parametrize (
55
+ 'invalid_css,remainder' , [
56
+ # No colon
57
+ ('hello-world' , '' ),
58
+ ('border-style: solid; hello-world' , 'border-style: solid' ),
59
+ ('border-style: solid; hello-world; font-weight: bold' ,
60
+ 'border-style: solid; font-weight: bold' ),
61
+ # Unclosed string
62
+ pytest .mark .xfail (('background-image: "abc' , '' ),
63
+ reason = 'Unclosed CSS strings not detected' ),
64
+ pytest .mark .xfail (('font-family: "abc' , '' ),
65
+ reason = 'Unclosed CSS strings not detected' ),
66
+ pytest .mark .xfail (('background-image: \' abc' , '' ),
67
+ reason = 'Unclosed CSS strings not detected' ),
68
+ pytest .mark .xfail (('font-family: \' abc' , '' ),
69
+ reason = 'Unclosed CSS strings not detected' ),
70
+ # Invalid size
71
+ ('font-size: blah' , 'font-size: 1em' ),
72
+ ('font-size: 1a2b' , 'font-size: 1em' ),
73
+ ('font-size: 1e5pt' , 'font-size: 1em' ),
74
+ ('font-size: 1+6pt' , 'font-size: 1em' ),
75
+ ('font-size: 1unknownunit' , 'font-size: 1em' ),
76
+ ('font-size: 10' , 'font-size: 1em' ),
77
+ ('font-size: 10 pt' , 'font-size: 1em' ),
78
+ ])
79
+ def test_css_parse_invalid (invalid_css , remainder ):
80
+ with pytest .warns (CSSWarning ):
81
+ assert_same_resolution (invalid_css , remainder )
82
+
83
+ # TODO: we should be checking that in other cases no warnings are raised
56
84
57
85
58
86
@pytest .mark .parametrize (
@@ -226,7 +254,3 @@ def test_css_relative_font_size(size, relative_to, resolved):
226
254
inherited = {'font-size' : relative_to }
227
255
assert_resolves ('font-size: %s' % size , {'font-size' : resolved },
228
256
inherited = inherited )
229
-
230
-
231
- def test_css_font_size_invalid ():
232
- pass # TODO
0 commit comments