mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
split up test
This commit is contained in:
parent
4bb78d53a3
commit
76a51270fa
|
@ -329,33 +329,36 @@ class TestCffi(AccessTest):
|
||||||
|
|
||||||
|
|
||||||
class TestImagePutPixelError(AccessTest):
|
class TestImagePutPixelError(AccessTest):
|
||||||
def test_putpixel_error_message(self):
|
IMAGE_MODES1 = ["L", "LA", "RGB", "RGBA"]
|
||||||
for mode, reason, accept_tuple in [
|
INVALID_TYPES1 = ["foo", 1.0, None]
|
||||||
("L", "color must be int or tuple", True),
|
|
||||||
("LA", "color must be int or tuple", True),
|
|
||||||
("RGB", "color must be int or tuple", True),
|
|
||||||
("RGBA", "color must be int or tuple", True),
|
|
||||||
("I", "color must be int", False),
|
|
||||||
("I;16", "color must be int", False),
|
|
||||||
("BGR;15", "color must be int", False),
|
|
||||||
]:
|
|
||||||
im = hopper(mode)
|
|
||||||
|
|
||||||
for v in ["foo", 1.0, None]:
|
@pytest.mark.parametrize("mode", IMAGE_MODES1)
|
||||||
with pytest.raises(TypeError, match=reason):
|
def test_putpixel_type_error1(self, mode):
|
||||||
im.putpixel((0, 0), v)
|
im = hopper(mode)
|
||||||
|
for v in self.INVALID_TYPES1:
|
||||||
|
with pytest.raises(TypeError, match="color must be int or tuple"):
|
||||||
|
im.putpixel((0, 0), v)
|
||||||
|
|
||||||
if not accept_tuple:
|
IMAGE_MODES2 = ["I", "I;16", "BGR;15"]
|
||||||
with pytest.raises(TypeError, match=reason):
|
INVALID_TYPES2 = [*INVALID_TYPES1, (10,)]
|
||||||
im.putpixel((0, 0), (10,))
|
|
||||||
|
|
||||||
with pytest.raises(OverflowError):
|
@pytest.mark.parametrize("mode", IMAGE_MODES2)
|
||||||
im.putpixel((0, 0), 2 ** 80)
|
def test_putpixel_type_error2(self, mode):
|
||||||
|
im = hopper(mode)
|
||||||
|
for v in self.INVALID_TYPES2:
|
||||||
|
with pytest.raises(TypeError, match="color must be int"):
|
||||||
|
im.putpixel((0, 0), v)
|
||||||
|
|
||||||
for mode in ["BGR;15"]:
|
@pytest.mark.parametrize("mode", IMAGE_MODES1 + IMAGE_MODES2)
|
||||||
im = hopper(mode)
|
def test_putpixel_overflow_error(self, mode):
|
||||||
with pytest.raises(ValueError, match="unrecognized image mode"):
|
im = hopper(mode)
|
||||||
im.putpixel((0, 0), 0)
|
with pytest.raises(OverflowError):
|
||||||
|
im.putpixel((0, 0), 2 ** 80)
|
||||||
|
|
||||||
|
def test_putpixel_unrecognized_mode(self):
|
||||||
|
im = hopper("BGR;15")
|
||||||
|
with pytest.raises(ValueError, match="unrecognized image mode"):
|
||||||
|
im.putpixel((0, 0), 0)
|
||||||
|
|
||||||
|
|
||||||
class TestEmbeddable:
|
class TestEmbeddable:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user