aboutsummaryrefslogtreecommitdiff
path: root/tests/test_colors.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_colors.py')
-rwxr-xr-xtests/test_colors.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_colors.py b/tests/test_colors.py
new file mode 100755
index 0000000..58988a5
--- /dev/null
+++ b/tests/test_colors.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+# *****************************************************************************
+# Copyright (C) 2019-2021 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
+# This file is part of the thcolor project, which is MIT-licensed.
+# *****************************************************************************
+""" Unit tests for the thcolor color decoding and management module. """
+
+import pytest
+from thcolor.angles import DegreesAngle
+from thcolor.colors import SRGBColor, HSLColor, HWBColor
+
+
+@pytest.mark.parametrize('color,expected', (
+ (SRGBColor.frombytes(0, 0, 255), (
+ '#0000FF',
+ )),
+ (SRGBColor.frombytes(1, 22, 242, alpha=.5), (
+ '#0116F2',
+ 'rgba(1, 22, 242, 50%)',
+ )),
+ (HSLColor(DegreesAngle(0), 1, .4), (
+ '#CC0000',
+ 'hsl(0deg, 100%, 40%)',
+ )),
+ (HSLColor(DegreesAngle(0), .5, 1, alpha=.2), (
+ '#FFFFFF',
+ 'rgba(255, 255, 255, 20%)',
+ 'hsla(0deg, 50%, 100%, 20%)',
+ )),
+ (HWBColor(DegreesAngle(127), blackness=.5), (
+ '#00800F',
+ 'hwb(127deg, 0%, 50%)',
+ )),
+))
+def test_css(color, expected):
+ assert color.css() == expected
+
+# End of file.