Skip to content

Commit 5e6dd59

Browse files
jrebackpcluo
authored andcommitted
TST: catch warnings in test_css (pandas-dev#16094)
closes pandas-dev#16033
1 parent a66a612 commit 5e6dd59

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pandas/tests/io/formats/test_css.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
from pandas.util import testing as tm
34
from pandas.io.formats.css import CSSResolver, CSSWarning
45

56

@@ -35,20 +36,23 @@ def test_css_parse_comments():
3536

3637

3738
@pytest.mark.xfail(reason='''we don't need to handle specificity
38-
markers like !important, but we should
39-
ignore them in the future''')
39+
markers like !important, but we should
40+
ignore them in the future''')
4041
def test_css_parse_specificity():
4142
assert_same_resolution('font-weight: bold', 'font-weight: bold !important')
4243

4344

4445
@pytest.mark.xfail(reason='Splitting CSS declarations not yet sensitive to '
45-
'; in CSS strings')
46+
'; in CSS strings')
4647
def test_css_parse_strings():
4748
# semicolons in strings
48-
assert_resolves('background-image: url(\'http://blah.com/foo?a;b=c\')',
49-
{'background-image': 'url(\'http://blah.com/foo?a;b=c\')'})
50-
assert_resolves('background-image: url("http://blah.com/foo?a;b=c")',
51-
{'background-image': 'url("http://blah.com/foo?a;b=c")'})
49+
with tm.assert_produces_warning(CSSWarning):
50+
assert_resolves(
51+
'background-image: url(\'http://blah.com/foo?a;b=c\')',
52+
{'background-image': 'url(\'http://blah.com/foo?a;b=c\')'})
53+
assert_resolves(
54+
'background-image: url("http://blah.com/foo?a;b=c")',
55+
{'background-image': 'url("http://blah.com/foo?a;b=c")'})
5256

5357

5458
@pytest.mark.parametrize(
@@ -77,7 +81,7 @@ def test_css_parse_strings():
7781
('font-size: 10 pt', 'font-size: 1em'),
7882
])
7983
def test_css_parse_invalid(invalid_css, remainder):
80-
with pytest.warns(CSSWarning):
84+
with tm.assert_produces_warning(CSSWarning):
8185
assert_same_resolution(invalid_css, remainder)
8286

8387
# TODO: we should be checking that in other cases no warnings are raised
@@ -115,7 +119,7 @@ def test_css_side_shorthands(shorthand, expansions):
115119
{top: '1pt', right: '4pt',
116120
bottom: '2pt', left: '0pt'})
117121

118-
with pytest.warns(CSSWarning):
122+
with tm.assert_produces_warning(CSSWarning):
119123
assert_resolves('%s: 1pt 1pt 1pt 1pt 1pt' % shorthand,
120124
{})
121125

0 commit comments

Comments
 (0)