예제 #1
0
파일: test_eq.py 프로젝트: bsoyka/pigment
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)
예제 #2
0
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)
예제 #3
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
예제 #4
0
def test_random_color_white(i):
    c = Color.random((255, 255), (255, 255), (255, 255))

    assert c.rgb == (255, 255, 255)
예제 #5
0
def test_random_color_black(i):
    c = Color.random((0, 0), (0, 0), (0, 0))

    assert c.rgb == (0, 0, 0)
예제 #6
0
def test_hls_to_rgb(expected, hls):
    c = Color(0, 0, 0)
    c.hls = hls
    assert c.rgb == expected.rgb
예제 #7
0
def test_hsv_to_rgb(expected, hsv):
    c = Color(0, 0, 0)
    c.hsv = hsv
    assert c.rgb == expected.rgb
예제 #8
0
def test_cmyk_to_rgb(expected, cmyk):
    c = Color(0, 0, 0)
    c.cmyk = cmyk
    assert c.rgb == expected.rgb
예제 #9
0
def test_hex_to_rgb(expected, hex_code):
    c = Color(0, 0, 0)
    c.hex_code = hex_code
    assert c.rgb == expected.rgb
예제 #10
0
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)),
예제 #11
0
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
예제 #12
0
파일: test_eq.py 프로젝트: bsoyka/pigment
def test_equal(color):
    assert Color(*color) == Color(*color)
    assert Color(*color) == color
    assert color == Color(*color)