Beispiel #1
0
 def test_lt(self):
     color_a = AlphaColor.from_int(0xefab380)
     color_b = AlphaColor.from_int(0xffab3ef)
     assert color_a < color_b
Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #8
0
 def test_valid(self):
     assert int(AlphaColor.from_rgba(0.6, 0.2, 0.8, 0.8)) == 0x9933cccc
Beispiel #9
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         AlphaColor.from_rgba(0.6, 0.2, 0xcc, 0.1)
Beispiel #10
0
 def test_eq(self):
     color_a = AlphaColor.from_int(0xefab332)
     color_b = AlphaColor.from_int(0xefab332)
     assert color_a == color_b
Beispiel #11
0
 def test_invalid(self, colorint):
     with pytest.raises(ValueError):
         AlphaColor.from_int(colorint)
Beispiel #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
Beispiel #13
0
 def test_ge(self):
     color_a = AlphaColor.from_int(0xefab321)
     color_b = AlphaColor.from_int(0xefab321)
     assert color_a >= color_b
Beispiel #14
0
 def test_gt(self):
     color_a = AlphaColor.from_int(0xffab332)
     color_b = AlphaColor.from_int(0xefab332)
     assert color_a > color_b
Beispiel #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
Beispiel #16
0
 def test_valid(self):
     assert int(AlphaColor.from_hsla(0.625, 0.15, 0.74, 0.8)) == 0xb3b8c7cc
Beispiel #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)
Beispiel #18
0
 def test_valid(self):
     assert int(AlphaColor.from_hsva(0.625, 0.15, 0.74, 0.8)) == 0xa0a7bdcc
Beispiel #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)
Beispiel #20
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         AlphaColor.from_hsva(25, 1.0, 0.74, 0.8)
Beispiel #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)
Beispiel #22
0
def test_hex():
    color = AlphaColor.from_int(0xabcdef12)
    assert hex(color) == "0xabcdef12"
Beispiel #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
Beispiel #24
0
def test_from_name(name, a, expected):
    color = AlphaColor.from_name(name, a)
    assert int(color) == expected
Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #28
0
 def test_alphacolor_comparison(self, func):
     color = Color.from_int(0xefab3)
     alphacolor = AlphaColor.from_name("red")
     assert getattr(color, func)(alphacolor) == NotImplemented
Beispiel #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)
Beispiel #30
0
 def test_ne(self):
     color_a = AlphaColor.from_int(0xffab322)
     color_b = AlphaColor.from_int(0xffab323)
     assert color_a != color_b