Example #1
0
 def test_valid(self, val, skip_types, expected):
     assert Color.to_int(val, skip_types) == expected
Example #2
0
 def test_repr(self):
     color = Color(0xeeff22aa)
     assert repr(color) == "<Color(4009697962)>"
Example #3
0
 def test_str(self):
     color = Color(0xeeff22aa)
     assert str(color) == "eeff22aa"
Example #4
0
 def test_invalid_init(self):
     with pytest.raises(ValueError):
         Color(-1)
Example #5
0
 def test_int(self):
     color = Color(0xeeff22aa)
     assert int(color) == 0xeeff22aa
Example #6
0
 def test_alpha(self):
     color = Color(0xeeff22aa)
     assert round(color.alpha, 2) == 0.93
Example #7
0
 def test_without_alpha(self):
     color = Color.from_rgba(0xef, 0xa1, 0xde)
     assert color.integer == 0xefa1de
Example #8
0
 def test_rgb(self, prop, color_hex, expected):
     color = Color(color_hex)
     assert getattr(color, prop) == expected
Example #9
0
 def test_valid_edit(self, prop, color_hex, arg, expected):
     """Edit a color which already has an alpha value"""
     color = Color(color_hex)
     setattr(color, prop, arg)
     assert color.integer == expected
Example #10
0
 def test_invalid_edit(self, prop, color_hex, arg):
     """Modifications that should raise exception"""
     color = Color(color_hex)
     with pytest.raises(ValueError):
         setattr(color, prop, arg)
Example #11
0
def test_from_name():
    assert Color.from_name('gainsboro') == Color(0xdcdcdc)
Example #12
0
 def test_invalid(self, val, skip_types):
     with pytest.raises(ValueError):
         assert Color.to_int(val, skip_types)