Skip to content

Commit 7c85d48

Browse files
committed
add test for hex_to_rgb 4- and 8-character hex codes
1 parent 80a94ec commit 7c85d48

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎tests/test_plotly_utils/colors/test_color_conversions.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ def test_hex_to_rgb_shorthand_3_digit():
2323
assert hex_to_rgb("#00f") == (0, 0, 255)
2424

2525

26+
@pytest.mark.parametrize("value", ["#abcd", "eb4d", "#12345678", "b24fa3d1"])
27+
def test_hex_to_rgb_warns_on_4_and_8_digits(value):
28+
warning_must_contain = "4-char" if len(value.lstrip("#")) == 4 else "8-char"
29+
with pytest.warns(UserWarning, match=warning_must_contain):
30+
hex_to_rgb(value)
31+
32+
2633
@pytest.mark.parametrize("value", ["#12345", "#1", "#1234567", "", "#"])
2734
def test_hex_to_rgb_rejects_other_lengths(value):
2835
# The section width was len // 3, so "#12345" returned a 5-tuple rather

0 commit comments

Comments
 (0)