예제 #1
0
 def test_valid(self):
     assert int(Color.from_rgb(0.6, 0.2, 0.8)) == 0x9933cc
예제 #2
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_rgb(0.6, 0.2, 0xcc)
예제 #3
0
 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
예제 #4
0
def test_from_rgb():
    assert int(Color.from_rgb(0.3569, 0.4510, 0.2902)) == 0x5b734a
예제 #5
0
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
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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
예제 #10
0
 def test_valid(self, attr, expected):
     color = Color.from_rgb(0.75, 0.45, 0.29)
     assert round(getattr(color.rgb, attr), 4) == expected
예제 #11
0
 def test_getter(self):
     color = Color.from_rgb(0.75, 0.45, 0.29)
     assert color.rgb.vals == (0.75, 0.45, 0.29)