test_color   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_color_hex_error() 0 4 2
A test_color_hex() 0 7 1
1
import pytest
2
3
from graphinate.color import color_hex
4
5
colors = [
6
    ([0, 0, 0], "#000000"),
7
    ([0.5, 0.5, 0.5], "#7f7f7f"),
8
    ([1, 1, 1], "#010101"),
9
    ([2, 2, 2], "#020202"),
10
    ([50, 50, 50], "#323232"),
11
    ([100, 100, 100], "#646464"),
12
    ([128, 128, 128], "#808080"),
13
    ([255, 255, 255], "#ffffff"),
14
    ("Not a Sequence", "Not a Sequence")
15
]
16
17
18
@pytest.mark.parametrize(('color', 'expected_color_hex'), colors)
19
def test_color_hex(color, expected_color_hex):
20
    # act
21
    actual_color_hex = color_hex(color)
22
23
    # assert
24
    assert actual_color_hex == expected_color_hex
25
26
27
def test_color_hex_error():
28
    with pytest.raises(ValueError,
29
                       match="Input values should either be a float between 0 and 1 or an int between 0 and 255"):
30
        _ = color_hex(["a", "b", "c"])
31