def test_not_equal(color1, color2): assert Color(*color1) != Color(*color2) assert Color(*color1) != color2 assert color1 != Color(*color2) assert Color(*color2) != Color(*color1) assert Color(*color2) != color1 assert color2 != Color(*color1)
def test_updating_1(): c = Color(255, 0, 0) assert c.rgb == (255, 0, 0) c.hex_code = "00ff00" assert c.rgb == (0, 255, 0) c.cmyk = (0, 0, 0, 100) assert c.rgb == (0, 0, 0) c.hsv = (0, 100, 100) assert c.rgb == (255, 0, 0) c.hue = 60 assert c.rgb == (255, 255, 0)
def test_random_color(i): c = Color.random() assert 0 <= c.rgb[0] <= 255 assert 0 <= c.rgb[1] <= 255 assert 0 <= c.rgb[2] <= 255
def test_random_color_white(i): c = Color.random((255, 255), (255, 255), (255, 255)) assert c.rgb == (255, 255, 255)
def test_random_color_black(i): c = Color.random((0, 0), (0, 0), (0, 0)) assert c.rgb == (0, 0, 0)
def test_hls_to_rgb(expected, hls): c = Color(0, 0, 0) c.hls = hls assert c.rgb == expected.rgb
def test_hsv_to_rgb(expected, hsv): c = Color(0, 0, 0) c.hsv = hsv assert c.rgb == expected.rgb
def test_cmyk_to_rgb(expected, cmyk): c = Color(0, 0, 0) c.cmyk = cmyk assert c.rgb == expected.rgb
def test_hex_to_rgb(expected, hex_code): c = Color(0, 0, 0) c.hex_code = hex_code assert c.rgb == expected.rgb
from pytest import mark from pigment import Color # pylint: disable=import-error BLACK = Color(0, 0, 0) WHITE = Color(255, 255, 255) RED = Color(255, 0, 0) GREEN = Color(0, 255, 0) BLUE = Color(0, 0, 255) @mark.parametrize( "expected,hex_code", [ (BLACK, "000000"), (WHITE, "ffffff"), (RED, "ff0000"), (GREEN, "00ff00"), (BLUE, "0000ff"), ], ) def test_hex_to_rgb(expected, hex_code): c = Color(0, 0, 0) c.hex_code = hex_code assert c.rgb == expected.rgb @mark.parametrize( "expected,cmyk", [ (BLACK, (0, 0, 0, 100)),
from pytest import mark from pigment import Color, blend # pylint: disable=import-error @mark.parametrize( "color1,color2,expected", [ (Color(255, 0, 0), Color(0, 255, 0), Color(180, 180, 0)), (Color(255, 0, 0), Color(0, 0, 255), Color(180, 0, 180)), (Color(0, 255, 0), Color(0, 0, 255), Color(0, 180, 180)), ], ) def test_blend(color1, color2, expected): assert blend(color1, color2).rgb == expected.rgb
def test_equal(color): assert Color(*color) == Color(*color) assert Color(*color) == color assert color == Color(*color)