예제 #1
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_hsv(25, 1.0, 0.74)
예제 #2
0
 def test_valid(self):
     assert int(Color.from_hsv(0.625, 0.15, 0.74)) == 0xa0a7bd
예제 #3
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)
예제 #4
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
예제 #5
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
예제 #6
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)
예제 #7
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
예제 #8
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
예제 #9
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]