Esempio n. 1
0
 def test_lt(self):
     color_a = AlphaColor.from_int(0xefab380)
     color_b = AlphaColor.from_int(0xffab3ef)
     assert color_a < color_b
Esempio n. 2
0
 def test_valid(self, attr, val):
     color = AlphaColor.from_hsva(0.45, 0.15, 0.89, 0.79)
     setattr(color.hsva, attr, val)
     assert round(getattr(color.hsva, attr), 4) == val
Esempio n. 3
0
def test_replace(hsva_dict, expected):
    color = AlphaColor.from_hsva(0.75, 0.45, 0.29, 0.5)
    assert int(color.hsva.replace(**hsva_dict)) == expected
Esempio n. 4
0
 def test_setter_valid(self, vals):
     color = AlphaColor.from_rgba(0.75, 0.45, 0.29, 0.2)  # rgba(191,115,74)
     color.rgba.vals = vals
     assert list(color.rgba) == list(vals)
Esempio n. 5
0
def test_vals_getter():
    vals = (0.75, 0.45, 0.29, 0.79)
    color = AlphaColor.from_hsva(0.75, 0.45, 0.29, 0.79)
    assert [round(val, 4) for val in color.hsva.vals] == list(vals)
Esempio n. 6
0
 def test_valid(self, attr, val):
     color = AlphaColor.from_rgba(0.75, 0.45, 0.29, 0.75)
     setattr(color.rgba, attr, val)
     assert round(getattr(color.rgba, attr), 4) == val
Esempio n. 7
0
def test_replace(rgba_dict, expected):
    color = AlphaColor.from_int(0xbf734a80)  # rgba(191,115,74,50%)
    assert int(color.rgba.replace(**rgba_dict)) == expected
Esempio n. 8
0
 def test_valid(self):
     assert int(AlphaColor.from_rgba(0.6, 0.2, 0.8, 0.8)) == 0x9933cccc
Esempio n. 9
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         AlphaColor.from_rgba(0.6, 0.2, 0xcc, 0.1)
Esempio n. 10
0
 def test_eq(self):
     color_a = AlphaColor.from_int(0xefab332)
     color_b = AlphaColor.from_int(0xefab332)
     assert color_a == color_b
Esempio n. 11
0
 def test_invalid(self, colorint):
     with pytest.raises(ValueError):
         AlphaColor.from_int(colorint)
Esempio n. 12
0
 def test_valid(self, colorint, rgba):
     color = AlphaColor.from_int(colorint)
     rounded_comps = [round(comp, 4) for comp in color.rgba]
     assert rounded_comps == rgba
Esempio n. 13
0
 def test_ge(self):
     color_a = AlphaColor.from_int(0xefab321)
     color_b = AlphaColor.from_int(0xefab321)
     assert color_a >= color_b
Esempio n. 14
0
 def test_gt(self):
     color_a = AlphaColor.from_int(0xffab332)
     color_b = AlphaColor.from_int(0xefab332)
     assert color_a > color_b
Esempio n. 15
0
 def test_setter_invalid(self, wrong_vals):
     color = AlphaColor.from_rgba(0.75, 0.45, 0.29, 0.1)  # rgba(191,115,74)
     with pytest.raises(ValueError):
         color.rgba.vals = wrong_vals
Esempio n. 16
0
 def test_valid(self):
     assert int(AlphaColor.from_hsla(0.625, 0.15, 0.74, 0.8)) == 0xb3b8c7cc
Esempio n. 17
0
 def test_vals(self):
     color = AlphaColor.from_rgba(0.75, 0.45, 0.29, 0.81)
     assert color.rgba.vals == (0.75, 0.45, 0.29, 0.81)
Esempio n. 18
0
 def test_valid(self):
     assert int(AlphaColor.from_hsva(0.625, 0.15, 0.74, 0.8)) == 0xa0a7bdcc
Esempio n. 19
0
 def test_invalid(self, attr):
     color = AlphaColor.from_rgba(0.75, 0.45, 0.29, 0.75)
     with pytest.raises(AttributeError):
         setattr(color.rgba, attr, 0.1)
Esempio n. 20
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         AlphaColor.from_hsva(25, 1.0, 0.74, 0.8)
Esempio n. 21
0
 def test_getter(self):
     color = AlphaColor.from_rgba(0.75, 0.45, 0.29, 0.75)
     color.rgba.vals = (0.2, 0.4, 0.6, 0.23)
     assert color.rgba.vals == (0.2, 0.4, 0.6, 0.23)
Esempio n. 22
0
def test_hex():
    color = AlphaColor.from_int(0xabcdef12)
    assert hex(color) == "0xabcdef12"
Esempio n. 23
0
 def test_setter_invalid(self, wrong_vals):
     color = AlphaColor.from_hsva(0.75, 0.45, 0.29, 0.79)
     with pytest.raises(ValueError):
         color.hsva.vals = wrong_vals
Esempio n. 24
0
def test_from_name(name, a, expected):
    color = AlphaColor.from_name(name, a)
    assert int(color) == expected
Esempio n. 25
0
 def test_valid(self, attr, expected):
     color = AlphaColor.from_hsva(0.75, 0.47, 0.29, 0.79)
     assert round(getattr(color.hsva, attr), 4) == expected
Esempio n. 26
0
def test_copy():
    orig = AlphaColor.from_hsla(0.2583, 0.1515, 0.7412, 0.25)
    copy = orig.copy()
    assert id(orig) != id(copy)
    assert orig.rgba.vals == copy.rgba.vals
Esempio n. 27
0
 def test_invalid(self, attr):
     color = AlphaColor.from_hsva(0.75, 0.47, 0.29, 0.79)
     with pytest.raises(AttributeError):
         setattr(color.hsva, attr, 0.1)
Esempio n. 28
0
 def test_alphacolor_comparison(self, func):
     color = Color.from_int(0xefab3)
     alphacolor = AlphaColor.from_name("red")
     assert getattr(color, func)(alphacolor) == NotImplemented
Esempio n. 29
0
 def test_setter_valid(self, vals):
     color = AlphaColor.from_hsva(0.75, 0.45, 0.29, 0.79)
     color.hsva.vals = vals
     assert [round(val, 4) for val in color.hsva] == list(vals)
Esempio n. 30
0
 def test_ne(self):
     color_a = AlphaColor.from_int(0xffab322)
     color_b = AlphaColor.from_int(0xffab323)
     assert color_a != color_b