예제 #1
0
def test_replace(rgb_dict, expected):
    color = Color.from_rgb(0.75, 0.45, 0.29)  # rgb(191,115,74)
    assert int(color.rgb.replace(**rgb_dict)) == expected
예제 #2
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_rgb(0.6, 0.2, 0xcc)
예제 #3
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_hsl(25, 1.0, 0.74)
예제 #4
0
 def test_alphacolor_comparison(self, func):
     color = Color.from_int(0xefab3)
     alphacolor = AlphaColor.from_name("red")
     assert getattr(color, func)(alphacolor) == NotImplemented
예제 #5
0
 def test_invalid(self, colorint):
     with pytest.raises(ValueError):
         Color.from_int(colorint)
예제 #6
0
def test_copy():
    orig = Color.from_hsl(0.2583, 0.1515, 0.7412)
    copy = orig.copy()
    assert id(orig) != id(copy)
    assert orig.rgb.vals == copy.rgb.vals
예제 #7
0
 def test_invalid_comparison(self, func, arg):
     color = Color.from_int(0xefab3)
     assert getattr(color, func)(arg) == NotImplemented
예제 #8
0
 def test_invalid(self, attr):
     color = Color.from_hsv(0.75, 0.47, 0.29)
     with pytest.raises(AttributeError):
         setattr(color.hsv, attr, 0.1)
예제 #9
0
def test_replace(hsv_dict, expected):
    color = Color.from_hsv(0.75, 0.45, 0.29)
    assert int(color.hsv.replace(**hsv_dict)) == expected
예제 #10
0
 def test_valid(self, attr, expected):
     color = Color.from_hsv(0.75, 0.47, 0.29)
     assert round(getattr(color.hsv, attr), 4) == expected
예제 #11
0
 def test_valid(self, attr, val):
     color = Color.from_hsv(0.45, 0.15, 0.89)
     setattr(color.hsv, attr, val)
     assert round(getattr(color.hsv, attr), 4) == val
예제 #12
0
def test_vals_getter():
    color = Color.from_hsv(0.75, 0.45, 0.29)
    assert [round(val, 4) for val in color.hsv.vals] == [0.75, 0.45, 0.29]
예제 #13
0
 def test_setter_invalid(self, wrong_vals):
     color = Color.from_rgb(0.75, 0.45, 0.29)  # rgb(191,115,74)
     with pytest.raises(ValueError):
         color.rgb.vals = wrong_vals
예제 #14
0
 def test_setter_valid(self, vals):
     color = Color.from_rgb(0.75, 0.45, 0.29)  # rgb(191,115,74)
     color.rgb.vals = vals
     assert list(color.rgb) == list(vals)
예제 #15
0
def test_from_rgb():
    assert int(Color.from_rgb(0.3569, 0.4510, 0.2902)) == 0x5b734a
예제 #16
0
 def test_setter_valid(self, vals):
     color = Color.from_hsv(0.75, 0.45, 0.29)
     color.hsv.vals = vals
     assert [round(val, 4) for val in color.hsv] == list(vals)
예제 #17
0
def test_from_hsl():
    assert int(Color.from_hsl(0.2583, 0.1515, 0.7412)) == 0xbcc7b3
예제 #18
0
 def test_setter_invalid(self, wrong_vals):
     color = Color.from_hsv(0.75, 0.45, 0.29)
     with pytest.raises(ValueError):
         color.hsv.vals = wrong_vals
예제 #19
0
 def test_gt(self):
     color_a = Color.from_int(0xffab3)
     color_b = Color.from_int(0xefab3)
     assert color_a > color_b
예제 #20
0
 def test_ne(self):
     color_a = Color.from_int(0xefab3)
     color_b = Color.from_int(0xffab3)
     assert color_a != color_b
예제 #21
0
 def test_eq(self):
     color_a = Color.from_int(0xefab3)
     color_b = Color.from_int(0xefab3)
     assert color_a == color_b
예제 #22
0
def test_str():
    color = Color.from_int(0xabcdef)
    assert str(color) == "abcdef"
예제 #23
0
 def test_valid(self, colorint, rgb):
     color = Color.from_int(colorint)
     rounded_comps = [round(comp, 4) for comp in color.rgb]
     assert rounded_comps == rgb
예제 #24
0
def test_repr():
    color = Color.from_int(0xabcdef)
    assert repr(color) == "<Color(0xabcdef)>"
예제 #25
0
 def test_valid(self):
     assert int(Color.from_rgb(0.6, 0.2, 0.8)) == 0x9933cc
예제 #26
0
def test_hex():
    color = Color.from_int(0xabcdef)
    assert hex(color) == "0xabcdef"
예제 #27
0
 def test_valid(self):
     assert int(Color.from_hsl(0.625, 0.15, 0.74)) == 0xb3b8c7
예제 #28
0
def test_from_name():
    color = Color.from_name("gray")
    assert int(color) == 0x808080
예제 #29
0
 def test_valid(self):
     assert int(Color.from_hsv(0.625, 0.15, 0.74)) == 0xa0a7bd
예제 #30
0
 def test_vals(self):
     color = Color.from_rgb(0.75, 0.45, 0.29)
     color.rgb.vals = (0.2, 0.4, 0.6)
     assert color.rgb.vals == (0.2, 0.4, 0.6)