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

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