Skip to content

Commit 7db59c0

Browse files
committed
Test inherited styles in converter
1 parent d103f61 commit 7db59c0

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pandas/formats/format.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ def __call__(self, declarations_str, inherited=None):
18261826

18271827
if val is None:
18281828
# we do not define a complete initial stylesheet
1829-
del props[val]
1829+
del props[prop]
18301830
else:
18311831
props[prop] = val
18321832

@@ -1984,7 +1984,8 @@ class CSSToExcelConverter(object):
19841984

19851985
def __init__(self, inherited=None):
19861986
if inherited is not None:
1987-
inherited = self.compute_css(inherited, sefl.INITIAL_STYLE)
1987+
inherited = self.compute_css(inherited,
1988+
self.compute_css.INITIAL_STYLE)
19881989

19891990
self.inherited = inherited
19901991

pandas/tests/formats/test_to_excel.py

+18
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,21 @@ def test_css_font_size_invalid():
176176
def test_css_to_excel(css, expected):
177177
convert = CSSToExcelConverter()
178178
assert expected == convert(css)
179+
180+
181+
@pytest.mark.parametrize('css,inherited,expected', [
182+
('font-weight: bold', '',
183+
{'font': {'bold': True}}),
184+
('', 'font-weight: bold',
185+
{'font': {'bold': True}}),
186+
('font-weight: bold', 'font-style: italic',
187+
{'font': {'bold': True, 'italic': True}}),
188+
('font-style: normal', 'font-style: italic',
189+
{'font': {'italic': False}}),
190+
('font-style: inherit', '', {}),
191+
('font-style: normal; font-style: inherit', 'font-style: italic',
192+
{'font': {'italic': True}}),
193+
])
194+
def test_css_to_excel_inherited(css, inherited, expected):
195+
convert = CSSToExcelConverter(inherited)
196+
assert expected == convert(css)

0 commit comments

Comments
 (0)