예제 #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