Skip to content

Commit d02d94e

Browse files
committed
Adding further coverage for excel.py
1 parent 4ac6f4e commit d02d94e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pandas/io/formats/excel.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,6 @@ def _get_decoration(self, props: Mapping[str, str]) -> Sequence[str]:
411411
else:
412412
return ()
413413

414-
def _get_underline(self, decoration: Sequence[str]) -> str | None:
415-
if "underline" in decoration:
416-
return "single"
417-
return None
418-
419414
def _get_shadow(self, props: Mapping[str, str]) -> bool | None:
420415
if "text-shadow" in props:
421416
return bool(re.search("^[^#(]*[1-9]", props["text-shadow"]))

pandas/tests/io/formats/test_to_excel.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,21 @@ def test_css_to_excel_bad_colors(input_color):
358358
convert = CSSToExcelConverter()
359359
assert expected == convert(css)
360360

361+
@pytest.mark.parametrize("input_color", ["#", "#1234567"])
362+
def test_css_to_excel_invalid_color_raises(input_color):
363+
"""Test that invalid colors raise a ValueError."""
364+
css = (
365+
f"border-top-color: {input_color}; "
366+
f"border-right-color: {input_color}; "
367+
f"border-bottom-color: {input_color}; "
368+
f"border-left-color: {input_color}; "
369+
f"background-color: {input_color}; "
370+
f"color: {input_color}"
371+
)
372+
373+
convert = CSSToExcelConverter()
374+
with pytest.raises(ValueError, match=f"Unexpected color {input_color}"):
375+
convert(css)
361376

362377
def tests_css_named_colors_valid():
363378
upper_hexs = set(map(str.upper, string.hexdigits))

0 commit comments

Comments
 (0)