1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.
|