diff --git a/tests/test_colour.py b/tests/test_colour.py index c1e3731..4c4ab61 100644 --- a/tests/test_colour.py +++ b/tests/test_colour.py @@ -1,3 +1,5 @@ +import pytest + from catppuccin.colour import Colour @@ -7,3 +9,21 @@ def test_colour_to_rgb(): def test_colour_to_hex(): assert Colour(0x12, 0xEB, 0x77).hex == "12eb77" + + +def test_hex_to_color(): + assert Colour.from_hex("12eb77") == Colour(0x12, 0xEB, 0x77) + + +def test_invalid_hex(): + for invalid_value in ("1234567", "12345", "Z00000", "ABCDEG", "0F7CBJ"): + with pytest.raises(ValueError): + assert Colour.from_hex(invalid_value) + + +def test_equality(): + assert Colour.from_hex("12eb77") == Colour.from_hex("12eb77") + assert Colour(0x12, 0xEB, 0x77) == Colour(0x12, 0xEB, 0x77) + + with pytest.raises(ValueError): + assert Colour(0x12, 0xEB, 0x77) == 42