Example #1
0
 def test_rgba_negative_opacity(self):
     with pytest.raises(InvalidColorValue):
         format_color("rgb(128, 32, 60, -0.5)")
Example #2
0
 def test_rgb_negative(self):
     with pytest.raises(InvalidColorValue):
         format_color("rgb(128, -32, 60)")
Example #3
0
 def test_rgb_overbound(self):
     with pytest.raises(InvalidColorValue):
         format_color("rgb(128, 192, 999)")
Example #4
0
 def test_insufficient_rgb_length(self):
     with pytest.raises(InvalidColorValue):
         format_color("rgb(128, 192)")
Example #5
0
 def test_excessive_rgb_length(self):
     with pytest.raises(InvalidColorValue):
         format_color("rgb(32, 64, 92, 128, 255)")
Example #6
0
 def test_excessive_iterable_length(self):
     with pytest.raises(InvalidColorValue):
         format_color([128, 96, 48, 255, 255])
Example #7
0
 def test_short_hexa(self):
     assert format_color("cde0") == (204, 221, 238, 0)
     assert format_color("#ff08") == (255, 255, 0, 136)
Example #8
0
 def test_iterable(self):
     assert format_color([32, 64, 128, 72]) == (32, 64, 128, 72)
Example #9
0
 def test_insufficient_hex_length(self):
     with pytest.raises(InvalidColorValue):
         format_color("FF")
Example #10
0
 def test_rgba(self):
     assert format_color("rgba(98, 212, 204, 0.89)") == (98, 212, 204, 227)
Example #11
0
 def test_short_iterable(self):
     assert format_color(["67", "120", "64"]) == (67, 120, 64, 255)
Example #12
0
 def test_rgb(self):
     assert format_color("rgb(75, 109, 26)") == (75, 109, 26, 255)
Example #13
0
 def test_hexa(self):
     assert format_color("C0B0D080") == (192, 176, 208, 128)
     assert format_color("#4B6D321A") == (75, 109, 50, 26)
Example #14
0
 def test_hex(self):
     assert format_color("DDA0C4") == (221, 160, 196, 255)
     assert format_color("#2F4BEF") == (47, 75, 239, 255)
Example #15
0
 def test_rgba_opacity_overbound(self):
     with pytest.raises(InvalidColorValue):
         format_color("rgba(128, 192, 0, 1.5)")
Example #16
0
 def test_excessive_hex_length(self):
     with pytest.raises(InvalidColorValue):
         format_color("FFAABBDDEE")
Example #17
0
 def test_insufficient_iterable_length(self):
     with pytest.raises(InvalidColorValue):
         format_color([64, 128])
Example #18
0
 def test_non_hex(self):
     with pytest.raises(InvalidColorValue):
         format_color("XYZ")
Example #19
0
    def test_invalid_type(self):
        with pytest.raises(InvalidColorType):
            format_color(None)

        with pytest.raises(InvalidColorType):
            format_color(192)
Example #20
0
 def test_short_hex(self):
     assert format_color("aac") == (170, 170, 204, 255)
     assert format_color("#da0") == (221, 170, 0, 255)