Add tests for negative number hsl handling, normalise degrees to range 0-1

This commit is contained in:
Darren Burns
2022-06-08 15:50:37 +01:00
committed by Will McGugan
parent adcce9d58f
commit 9c7d7b703e
3 changed files with 17 additions and 4 deletions

View File

@@ -1,5 +1,4 @@
import pytest
from rich.color import Color as RichColor
from rich.text import Text
@@ -136,6 +135,15 @@ def test_color_parse_clamp(input, output):
assert Color.parse(input) == output
def test_color_parse_hsl_negative_degrees():
assert Color.parse("hsl(-90, 50%, 50%)") == Color.parse("hsl(270, 50%, 50%)")
def test_color_parse_hsla_negative_degrees():
assert Color.parse("hsla(-45, 50%, 50%, 0.2)") == Color.parse(
"hsla(315, 50%, 50%, 0.2)")
def test_color_parse_color():
# as a convenience, if Color.parse is passed a color object, it will return it
color = Color(20, 30, 40, 0.5)