Skip to content

Commit

Permalink
Parametrized test
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 10, 2022
1 parent beb7b4d commit ed016f8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Tests/test_file_tiff.py
Expand Up @@ -84,22 +84,23 @@ def test_context_manager(self):
with Image.open("Tests/images/multipage.tiff") as im:
im.load()

def test_get_child_images(self):
def check(ims, sizes):
assert len(ims) == len(sizes)

for i, im in enumerate(ims):
w = sizes[i]
expected = Image.new("RGB", (w, w), "#f00")
assert_image_similar(im, expected, 1)

with Image.open("Tests/images/child_ifd.tiff") as im:
@pytest.mark.parametrize(
"path, sizes",
(
("Tests/images/hopper.tif", ()),
("Tests/images/child_ifd.tiff", (16, 8)),
("Tests/images/child_ifd_jpeg.tiff", (20,)),
),
)
def test_get_child_images(self, path, sizes):
with Image.open(path) as im:
ims = im.get_child_images()
check(ims, (16, 8))

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

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

0 comments on commit ed016f8

Please sign in to comment.