Пример #1
0
def test_colours():
    """Test colour conversions.
    """
    assert rgb_to_hex([0, 0, 0]) == '#000000'
    assert rgb_to_hex([255, 128, 128]) == '#FF8080'
    assert hex_to_rgb('#000000') == (0, 0, 0)
    assert hex_to_rgb('#ff8080') == (255, 128, 128)  # case
Пример #2
0
def test_colours():
    """Test colour conversions.
    """
    assert rgb_to_hex([0, 0, 0]) == '#000000'
    assert rgb_to_hex([0, 0.5, 0.5]) == '#008080'
    assert rgb_to_hex([255, 128, 128]) == '#ff8080'
    assert hex_to_rgb('#000000') == (0, 0, 0)
    assert hex_to_rgb('#ff8080') == (255, 128, 128)  # case

    # And exceptions:
    with pytest.raises(Exception):
        _ = rgb_to_hex([0, 0, -1])
        assert _

    with pytest.raises(Exception):
        _ = rgb_to_hex([0, 0, 256])
        assert _

    with pytest.raises(Exception):
        _ = rgb_to_hex([0, 0.1, 2])
        assert _
Пример #3
0
def test_colours():
    assert rgb_to_hex([0, 0, 0]) == '#000000'
    assert rgb_to_hex([255, 128, 128]) == '#FF8080'
    assert hex_to_rgb('#000000') == (0, 0, 0)
    assert hex_to_rgb('#ff8080') == (255, 128, 128)  # case
Пример #4
0
def test_colours():
    assert rgb_to_hex([0, 0, 0]) == '#000000'
    assert rgb_to_hex([255, 128, 128]) == '#FF8080'
    assert hex_to_rgb('#000000') == (0, 0, 0)
    assert hex_to_rgb('#ff8080') == (255, 128, 128)  # case
Пример #5
0
def test_colours():
    assert rgb_to_hex([0, 0, 0]) == "#000000"
    assert rgb_to_hex([255, 128, 128]) == "#FF8080"
    assert hex_to_rgb("#000000") == (0, 0, 0)
    assert hex_to_rgb("#ff8080") == (255, 128, 128)  # case