mirror of
https://github.com/catppuccin/python.git
synced 2026-02-04 14:13:16 +08:00
test: Add unittest for hex to color
This commit is contained in:
parent
bef684afd4
commit
105905ea44
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user