|
156 | 156 | "border-top-style: solid; border-top-width: 4pt",
|
157 | 157 | {"border": {"top": {"style": "thick"}}},
|
158 | 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"}}}, |
| 166 | + ), |
159 | 167 | (
|
160 | 168 | "border-top-style: dotted",
|
161 | 169 | {"border": {"top": {"style": "mediumDashDotDot"}}},
|
|
194 | 202 | "border-top-color: blue",
|
195 | 203 | {"border": {"top": {"color": "0000FF", "style": "none"}}},
|
196 | 204 | ),
|
| 205 | + ( |
| 206 | + "border-top-style: slantDashDot; border-top-color: blue", |
| 207 | + {"border": {"top": {"style": "slantDashDot", "color": "0000FF"}}}, |
| 208 | + ), |
197 | 209 | # ALIGNMENT
|
198 | 210 | # - horizontal
|
199 | 211 | ("text-align: center", {"alignment": {"horizontal": "center"}}),
|
@@ -249,6 +261,20 @@ def test_css_to_excel_multiple():
|
249 | 261 | } == actual
|
250 | 262 |
|
251 | 263 |
|
| 264 | +@pytest.mark.parametrize( |
| 265 | + "css", |
| 266 | + [ |
| 267 | + "border-top-style: unhandled-border-style", |
| 268 | + "border-style: another-unhandled-style", |
| 269 | + ], |
| 270 | +) |
| 271 | +def test_css_to_excel_unhandled_border_style_warns(css): |
| 272 | + """Test that unhandled border styles raise a CSSWarning.""" |
| 273 | + convert = CSSToExcelConverter() |
| 274 | + with tm.assert_produces_warning(CSSWarning, match="Unhandled border style format"): |
| 275 | + convert(css) |
| 276 | + |
| 277 | + |
252 | 278 | @pytest.mark.parametrize(
|
253 | 279 | "css,inherited,expected",
|
254 | 280 | [
|
@@ -330,6 +356,23 @@ def test_css_to_excel_bad_colors(input_color):
|
330 | 356 | assert expected == convert(css)
|
331 | 357 |
|
332 | 358 |
|
| 359 | +@pytest.mark.parametrize("input_color", ["#", "#1234567"]) |
| 360 | +def test_css_to_excel_invalid_color_raises(input_color): |
| 361 | + """Test that invalid colors raise a ValueError.""" |
| 362 | + css = ( |
| 363 | + f"border-top-color: {input_color}; " |
| 364 | + f"border-right-color: {input_color}; " |
| 365 | + f"border-bottom-color: {input_color}; " |
| 366 | + f"border-left-color: {input_color}; " |
| 367 | + f"background-color: {input_color}; " |
| 368 | + f"color: {input_color}" |
| 369 | + ) |
| 370 | + |
| 371 | + convert = CSSToExcelConverter() |
| 372 | + with pytest.raises(ValueError, match=f"Unexpected color {input_color}"): |
| 373 | + convert(css) |
| 374 | + |
| 375 | + |
333 | 376 | def tests_css_named_colors_valid():
|
334 | 377 | upper_hexs = set(map(str.upper, string.hexdigits))
|
335 | 378 | for color in CSSToExcelConverter.NAMED_COLORS.values():
|
|
0 commit comments