Skip to content

Commit

Permalink
Test inherited styles in converter
Browse files Browse the repository at this point in the history
  • Loading branch information
jnothman committed Apr 5, 2017
1 parent d103f61 commit 7db59c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pandas/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ def __call__(self, declarations_str, inherited=None):

if val is None:
# we do not define a complete initial stylesheet
del props[val]
del props[prop]
else:
props[prop] = val

Expand Down Expand Up @@ -1984,7 +1984,8 @@ class CSSToExcelConverter(object):

def __init__(self, inherited=None):
if inherited is not None:
inherited = self.compute_css(inherited, sefl.INITIAL_STYLE)
inherited = self.compute_css(inherited,
self.compute_css.INITIAL_STYLE)

self.inherited = inherited

Expand Down
18 changes: 18 additions & 0 deletions pandas/tests/formats/test_to_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,21 @@ def test_css_font_size_invalid():
def test_css_to_excel(css, expected):
convert = CSSToExcelConverter()
assert expected == convert(css)


@pytest.mark.parametrize('css,inherited,expected', [
('font-weight: bold', '',
{'font': {'bold': True}}),
('', 'font-weight: bold',
{'font': {'bold': True}}),
('font-weight: bold', 'font-style: italic',
{'font': {'bold': True, 'italic': True}}),
('font-style: normal', 'font-style: italic',
{'font': {'italic': False}}),
('font-style: inherit', '', {}),
('font-style: normal; font-style: inherit', 'font-style: italic',
{'font': {'italic': True}}),
])
def test_css_to_excel_inherited(css, inherited, expected):
convert = CSSToExcelConverter(inherited)
assert expected == convert(css)

0 comments on commit 7db59c0

Please sign in to comment.