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
|
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2019 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 import Color
@pytest.mark.parametrize('test_input,expected', (
('blue', ( 0, 0, 255, 1.0)),
('#12345F', ( 18, 52, 95, 1.0)),
('#123', ( 17, 34, 51, 1.0)),
('123', ( 1, 2, 3, 1.0)),
('123.0', ( 18, 48, 0, 1.0)),
('chucknorris', (192, 0, 0, 1.0)),
('rgb(1, 22,242)', ( 1, 22, 242, 1.0)),
(' rgb (1,22, 242 , 50.0% )', ( 1, 22, 242, 0.5)),
('rgba(1,22,242,0.500)', ( 1, 22, 242, 0.5)),
('rbga(5, 7)', ( 5, 0, 7, 1.0)),
('hsl(0, 1,50.0%)', (255, 0, 0, 1.0))))
def test_rgba(test_input, expected):
assert Color.from_text(test_input).rgba() == expected
# End of file.
|