def test_lt(self): color_a = AlphaColor.from_int(0xefab380) color_b = AlphaColor.from_int(0xffab3ef) assert color_a < color_b
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
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
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)
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)
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
def test_replace(rgba_dict, expected): color = AlphaColor.from_int(0xbf734a80) # rgba(191,115,74,50%) assert int(color.rgba.replace(**rgba_dict)) == expected
def test_valid(self): assert int(AlphaColor.from_rgba(0.6, 0.2, 0.8, 0.8)) == 0x9933cccc
def test_invalid(self): with pytest.raises(ValueError): AlphaColor.from_rgba(0.6, 0.2, 0xcc, 0.1)
def test_eq(self): color_a = AlphaColor.from_int(0xefab332) color_b = AlphaColor.from_int(0xefab332) assert color_a == color_b
def test_invalid(self, colorint): with pytest.raises(ValueError): AlphaColor.from_int(colorint)
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
def test_ge(self): color_a = AlphaColor.from_int(0xefab321) color_b = AlphaColor.from_int(0xefab321) assert color_a >= color_b
def test_gt(self): color_a = AlphaColor.from_int(0xffab332) color_b = AlphaColor.from_int(0xefab332) assert color_a > color_b
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
def test_valid(self): assert int(AlphaColor.from_hsla(0.625, 0.15, 0.74, 0.8)) == 0xb3b8c7cc
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)
def test_valid(self): assert int(AlphaColor.from_hsva(0.625, 0.15, 0.74, 0.8)) == 0xa0a7bdcc
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)
def test_invalid(self): with pytest.raises(ValueError): AlphaColor.from_hsva(25, 1.0, 0.74, 0.8)
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)
def test_hex(): color = AlphaColor.from_int(0xabcdef12) assert hex(color) == "0xabcdef12"
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
def test_from_name(name, a, expected): color = AlphaColor.from_name(name, a) assert int(color) == expected
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
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
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)
def test_alphacolor_comparison(self, func): color = Color.from_int(0xefab3) alphacolor = AlphaColor.from_name("red") assert getattr(color, func)(alphacolor) == NotImplemented
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)
def test_ne(self): color_a = AlphaColor.from_int(0xffab322) color_b = AlphaColor.from_int(0xffab323) assert color_a != color_b