parametrize Tests/test_image_paste.py

This commit is contained in:
Yay295 2022-08-22 09:23:42 -05:00
parent 5a087ccbb9
commit fd47eed73a

View File

@ -1,3 +1,5 @@
import pytest
from PIL import Image from PIL import Image
from .helper import CachedProperty, assert_image_equal from .helper import CachedProperty, assert_image_equal
@ -101,8 +103,12 @@ class TestImagingPaste:
], ],
) )
def test_image_solid(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_image_solid(self, mode):
im = Image.new(mode, (200, 200), "red") im = Image.new(mode, (200, 200), "red")
im2 = getattr(self, "gradient_" + mode) im2 = getattr(self, "gradient_" + mode)
@ -111,8 +117,12 @@ class TestImagingPaste:
im = im.crop((12, 23, im2.width + 12, im2.height + 23)) im = im.crop((12, 23, im2.width + 12, im2.height + 23))
assert_image_equal(im, im2) assert_image_equal(im, im2)
def test_image_mask_1(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_image_mask_1(self, mode):
im = Image.new(mode, (200, 200), "white") im = Image.new(mode, (200, 200), "white")
im2 = getattr(self, "gradient_" + mode) im2 = getattr(self, "gradient_" + mode)
@ -133,8 +143,12 @@ class TestImagingPaste:
], ],
) )
def test_image_mask_L(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_image_mask_L(self, mode):
im = Image.new(mode, (200, 200), "white") im = Image.new(mode, (200, 200), "white")
im2 = getattr(self, "gradient_" + mode) im2 = getattr(self, "gradient_" + mode)
@ -155,8 +169,12 @@ class TestImagingPaste:
], ],
) )
def test_image_mask_LA(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_image_mask_LA(self, mode):
im = Image.new(mode, (200, 200), "white") im = Image.new(mode, (200, 200), "white")
im2 = getattr(self, "gradient_" + mode) im2 = getattr(self, "gradient_" + mode)
@ -177,8 +195,12 @@ class TestImagingPaste:
], ],
) )
def test_image_mask_RGBA(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_image_mask_RGBA(self, mode):
im = Image.new(mode, (200, 200), "white") im = Image.new(mode, (200, 200), "white")
im2 = getattr(self, "gradient_" + mode) im2 = getattr(self, "gradient_" + mode)
@ -199,8 +221,12 @@ class TestImagingPaste:
], ],
) )
def test_image_mask_RGBa(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_image_mask_RGBa(self, mode):
im = Image.new(mode, (200, 200), "white") im = Image.new(mode, (200, 200), "white")
im2 = getattr(self, "gradient_" + mode) im2 = getattr(self, "gradient_" + mode)
@ -221,8 +247,12 @@ class TestImagingPaste:
], ],
) )
def test_color_solid(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_color_solid(self, mode):
im = Image.new(mode, (200, 200), "black") im = Image.new(mode, (200, 200), "black")
rect = (12, 23, 128 + 12, 128 + 23) rect = (12, 23, 128 + 12, 128 + 23)
@ -234,8 +264,12 @@ class TestImagingPaste:
assert head[255] == 128 * 128 assert head[255] == 128 * 128
assert sum(head[:255]) == 0 assert sum(head[:255]) == 0
def test_color_mask_1(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_color_mask_1(self, mode):
im = Image.new(mode, (200, 200), (50, 60, 70, 80)[: len(mode)]) im = Image.new(mode, (200, 200), (50, 60, 70, 80)[: len(mode)])
color = (10, 20, 30, 40)[: len(mode)] color = (10, 20, 30, 40)[: len(mode)]
@ -256,8 +290,12 @@ class TestImagingPaste:
], ],
) )
def test_color_mask_L(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_color_mask_L(self, mode):
im = getattr(self, "gradient_" + mode).copy() im = getattr(self, "gradient_" + mode).copy()
color = "white" color = "white"
@ -278,8 +316,12 @@ class TestImagingPaste:
], ],
) )
def test_color_mask_RGBA(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_color_mask_RGBA(self, mode):
im = getattr(self, "gradient_" + mode).copy() im = getattr(self, "gradient_" + mode).copy()
color = "white" color = "white"
@ -300,8 +342,12 @@ class TestImagingPaste:
], ],
) )
def test_color_mask_RGBa(self): @pytest.mark.parametrize("mode", [
for mode in ("RGBA", "RGB", "L"): "RGBA",
"RGB",
"L",
])
def test_color_mask_RGBa(self, mode):
im = getattr(self, "gradient_" + mode).copy() im = getattr(self, "gradient_" + mode).copy()
color = "white" color = "white"