Ejemplo n.º 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
Ejemplo n.º 2
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_rgb(0.6, 0.2, 0xcc)
Ejemplo n.º 3
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_hsl(25, 1.0, 0.74)
Ejemplo n.º 4
0
 def test_alphacolor_comparison(self, func):
     color = Color.from_int(0xefab3)
     alphacolor = AlphaColor.from_name("red")
     assert getattr(color, func)(alphacolor) == NotImplemented
Ejemplo n.º 5
0
 def test_invalid(self, colorint):
     with pytest.raises(ValueError):
         Color.from_int(colorint)
Ejemplo n.º 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
Ejemplo n.º 7
0
 def test_invalid_comparison(self, func, arg):
     color = Color.from_int(0xefab3)
     assert getattr(color, func)(arg) == NotImplemented
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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]
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 15
0
def test_from_rgb():
    assert int(Color.from_rgb(0.3569, 0.4510, 0.2902)) == 0x5b734a
Ejemplo n.º 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)
Ejemplo n.º 17
0
def test_from_hsl():
    assert int(Color.from_hsl(0.2583, 0.1515, 0.7412)) == 0xbcc7b3
Ejemplo n.º 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
Ejemplo n.º 19
0
 def test_gt(self):
     color_a = Color.from_int(0xffab3)
     color_b = Color.from_int(0xefab3)
     assert color_a > color_b
Ejemplo n.º 20
0
 def test_ne(self):
     color_a = Color.from_int(0xefab3)
     color_b = Color.from_int(0xffab3)
     assert color_a != color_b
Ejemplo n.º 21
0
 def test_eq(self):
     color_a = Color.from_int(0xefab3)
     color_b = Color.from_int(0xefab3)
     assert color_a == color_b
Ejemplo n.º 22
0
def test_str():
    color = Color.from_int(0xabcdef)
    assert str(color) == "abcdef"
Ejemplo n.º 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
Ejemplo n.º 24
0
def test_repr():
    color = Color.from_int(0xabcdef)
    assert repr(color) == "<Color(0xabcdef)>"
Ejemplo n.º 25
0
 def test_valid(self):
     assert int(Color.from_rgb(0.6, 0.2, 0.8)) == 0x9933cc
Ejemplo n.º 26
0
def test_hex():
    color = Color.from_int(0xabcdef)
    assert hex(color) == "0xabcdef"
Ejemplo n.º 27
0
 def test_valid(self):
     assert int(Color.from_hsl(0.625, 0.15, 0.74)) == 0xb3b8c7
Ejemplo n.º 28
0
def test_from_name():
    color = Color.from_name("gray")
    assert int(color) == 0x808080
Ejemplo n.º 29
0
 def test_valid(self):
     assert int(Color.from_hsv(0.625, 0.15, 0.74)) == 0xa0a7bd
Ejemplo n.º 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)