Exemplo n.º 1
0
 def test_valid(self):
     assert int(Color.from_hsl(0.625, 0.15, 0.74)) == 0xb3b8c7
Exemplo n.º 2
0
 def test_invalid(self):
     with pytest.raises(ValueError):
         Color.from_hsl(25, 1.0, 0.74)
Exemplo n.º 3
0
def test_from_hsl():
    assert int(Color.from_hsl(0.2583, 0.1515, 0.7412)) == 0xbcc7b3
Exemplo n.º 4
0
def test_copy():
    orig = Color.from_hsl(0.2583, 0.1515, 0.7412)
    copy = orig.copy()
    assert id(orig) != id(copy)
    assert orig.rgb.vals == copy.rgb.vals
Exemplo n.º 5
0
 def test_setter_invalid(self, wrong_vals):
     color = Color.from_hsl(0.75, 0.45, 0.29)
     with pytest.raises(ValueError):
         color.hsl.vals = wrong_vals
Exemplo n.º 6
0
def test_vals_getter():
    color = Color.from_hsl(0.75, 0.45, 0.29)
    assert [round(val, 4) for val in color.hsl.vals] == [0.75, 0.45, 0.29]
Exemplo n.º 7
0
 def test_setter_valid(self, vals):
     color = Color.from_hsl(0.75, 0.45, 0.29)
     color.hsl.vals = vals
     assert [round(val, 4) for val in color.hsl] == list(vals)
Exemplo n.º 8
0
def test_replace(hsl_dict, expected):
    color = Color.from_hsl(0.75, 0.45, 0.29)
    assert int(color.hsl.replace(**hsl_dict)) == expected
Exemplo n.º 9
0
 def test_invalid(self, attr):
     color = Color.from_hsl(0.75, 0.47, 0.29)
     with pytest.raises(AttributeError):
         setattr(color.hsl, attr, 0.1)
Exemplo n.º 10
0
 def test_valid(self, attr, val):
     color = Color.from_hsl(0.45, 0.15, 0.89)
     setattr(color.hsl, attr, val)
     assert round(getattr(color.hsl, attr), 4) == val
Exemplo n.º 11
0
 def test_valid(self, attr, expected):
     color = Color.from_hsl(0.75, 0.47, 0.29)
     assert round(getattr(color.hsl, attr), 4) == expected