Skip to content

TST: catch warnings in test_css #16094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions pandas/tests/io/formats/test_css.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from pandas.util import testing as tm
from pandas.io.formats.css import CSSResolver, CSSWarning


Expand Down Expand Up @@ -35,20 +36,23 @@ def test_css_parse_comments():


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


@pytest.mark.xfail(reason='Splitting CSS declarations not yet sensitive to '
'; in CSS strings')
'; in CSS strings')
def test_css_parse_strings():
# semicolons in strings
assert_resolves('background-image: url(\'http://blah.com/foo?a;b=c\')',
{'background-image': 'url(\'http://blah.com/foo?a;b=c\')'})
assert_resolves('background-image: url("http://blah.com/foo?a;b=c")',
{'background-image': 'url("http://blah.com/foo?a;b=c")'})
with tm.assert_produces_warning(CSSWarning):
assert_resolves(
'background-image: url(\'http://blah.com/foo?a;b=c\')',
{'background-image': 'url(\'http://blah.com/foo?a;b=c\')'})
assert_resolves(
'background-image: url("http://blah.com/foo?a;b=c")',
{'background-image': 'url("http://blah.com/foo?a;b=c")'})


@pytest.mark.parametrize(
Expand Down Expand Up @@ -77,7 +81,7 @@ def test_css_parse_strings():
('font-size: 10 pt', 'font-size: 1em'),
])
def test_css_parse_invalid(invalid_css, remainder):
with pytest.warns(CSSWarning):
with tm.assert_produces_warning(CSSWarning):
assert_same_resolution(invalid_css, remainder)

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

with pytest.warns(CSSWarning):
with tm.assert_produces_warning(CSSWarning):
assert_resolves('%s: 1pt 1pt 1pt 1pt 1pt' % shorthand,
{})

Expand Down