Skip to content

Commit ed016f8

Browse files
authored
Parametrized test
1 parent beb7b4d commit ed016f8

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

Tests/test_file_tiff.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,23 @@ def test_context_manager(self):
8484
with Image.open("Tests/images/multipage.tiff") as im:
8585
im.load()
8686

87-
def test_get_child_images(self):
88-
def check(ims, sizes):
89-
assert len(ims) == len(sizes)
90-
91-
for i, im in enumerate(ims):
92-
w = sizes[i]
93-
expected = Image.new("RGB", (w, w), "#f00")
94-
assert_image_similar(im, expected, 1)
95-
96-
with Image.open("Tests/images/child_ifd.tiff") as im:
87+
@pytest.mark.parametrize(
88+
"path, sizes",
89+
(
90+
("Tests/images/hopper.tif", ()),
91+
("Tests/images/child_ifd.tiff", (16, 8)),
92+
("Tests/images/child_ifd_jpeg.tiff", (20,)),
93+
),
94+
)
95+
def test_get_child_images(self, path, sizes):
96+
with Image.open(path) as im:
9797
ims = im.get_child_images()
98-
check(ims, (16, 8))
9998

100-
with Image.open("Tests/images/child_ifd_jpeg.tiff") as im:
101-
ims = im.get_child_images()
102-
check(ims, (20,))
99+
assert len(ims) == len(sizes)
100+
for i, im in enumerate(ims):
101+
w = sizes[i]
102+
expected = Image.new("RGB", (w, w), "#f00")
103+
assert_image_similar(im, expected, 1)
103104

104105
def test_mac_tiff(self):
105106
# Read RGBa images from macOS [@PIL136]

0 commit comments

Comments
 (0)