def test_valid(self): assert int(Color.from_rgb(0.6, 0.2, 0.8)) == 0x9933cc
def test_invalid(self): with pytest.raises(ValueError): Color.from_rgb(0.6, 0.2, 0xcc)
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
def test_from_rgb(): assert int(Color.from_rgb(0.3569, 0.4510, 0.2902)) == 0x5b734a
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
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)
def test_invalid(self, attr): color = Color.from_rgb(0.75, 0.45, 0.29) with pytest.raises(AttributeError): setattr(color.rgb, attr, 0.1)
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)
def test_valid(self, attr, val): color = Color.from_rgb(0.75, 0.45, 0.29) setattr(color.rgb, attr, val) assert round(getattr(color.rgb, attr), 4) == val
def test_valid(self, attr, expected): color = Color.from_rgb(0.75, 0.45, 0.29) assert round(getattr(color.rgb, attr), 4) == expected
def test_getter(self): color = Color.from_rgb(0.75, 0.45, 0.29) assert color.rgb.vals == (0.75, 0.45, 0.29)