Skip to content

Commit 4ac6f4e

Browse files
committed
Added coverage 314-349 and change in excel.py
1 parent 592a41a commit 4ac6f4e

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

pandas/io/formats/excel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ def _border_style(
303303
# 'slantDashDot'
304304
# 'thick'
305305
# 'thin'
306-
if width is None and style is None and color is None:
307-
# Return None will remove "border" from style dictionary
308-
return None
309-
310306
if width is None and style is None:
311-
# Return "none" will keep "border" in style dictionary
312-
return "none"
307+
if color is None:
308+
# Return None will remove "border" from style dictionary
309+
return None
310+
else:
311+
# Return "none" will keep "border" in style dictionary
312+
return "none"
313313

314314
if style in ("none", "hidden"):
315315
return "none"

pandas/tests/io/formats/test_to_excel.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@
155155
(
156156
"border-top-style: solid; border-top-width: 4pt",
157157
{"border": {"top": {"style": "thick"}}},
158+
),
159+
(
160+
"border-top-style: solid; border-top-width: none",
161+
{"border": {"top": {"style": "none"}}},
162+
),
163+
(
164+
"border-top-style: solid; border-top-width: 0.000001pt",
165+
{"border": {"top": {"style": "none"}}},
158166
),
159167
(
160168
"border-top-style: dotted",
@@ -194,6 +202,12 @@
194202
"border-top-color: blue",
195203
{"border": {"top": {"color": "0000FF", "style": "none"}}},
196204
),
205+
(
206+
"border-top-style: slantDashDot; border-top-color: blue",
207+
{"border": {"top": {"style": "slantDashDot", "color": "0000FF"}}},
208+
),
209+
210+
197211
# ALIGNMENT
198212
# - horizontal
199213
("text-align: center", {"alignment": {"horizontal": "center"}}),
@@ -249,6 +263,21 @@ def test_css_to_excel_multiple():
249263
} == actual
250264

251265

266+
@pytest.mark.parametrize(
267+
"css",
268+
[
269+
"border-top-style: unhandled-border-style",
270+
"border-style: another-unhandled-style",
271+
],
272+
)
273+
274+
def test_css_to_excel_unhandled_border_style_warns(css):
275+
"""Test that unhandled border styles raise a CSSWarning."""
276+
convert = CSSToExcelConverter()
277+
with tm.assert_produces_warning(CSSWarning, match="Unhandled border style format"):
278+
convert(css)
279+
280+
252281
@pytest.mark.parametrize(
253282
"css,inherited,expected",
254283
[

0 commit comments

Comments
 (0)