Skip to content

Commit 105905e

Browse files
Sigmanificientbackwardspy
authored andcommitted
test: Add unittest for hex to color
1 parent bef684a commit 105905e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_colour.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from catppuccin.colour import Colour
24

35

@@ -7,3 +9,21 @@ def test_colour_to_rgb():
79

810
def test_colour_to_hex():
911
assert Colour(0x12, 0xEB, 0x77).hex == "12eb77"
12+
13+
14+
def test_hex_to_color():
15+
assert Colour.from_hex("12eb77") == Colour(0x12, 0xEB, 0x77)
16+
17+
18+
def test_invalid_hex():
19+
for invalid_value in ("1234567", "12345", "Z00000", "ABCDEG", "0F7CBJ"):
20+
with pytest.raises(ValueError):
21+
assert Colour.from_hex(invalid_value)
22+
23+
24+
def test_equality():
25+
assert Colour.from_hex("12eb77") == Colour.from_hex("12eb77")
26+
assert Colour(0x12, 0xEB, 0x77) == Colour(0x12, 0xEB, 0x77)
27+
28+
with pytest.raises(ValueError):
29+
assert Colour(0x12, 0xEB, 0x77) == 42

0 commit comments

Comments
 (0)