Skip to content

Commit 28c89b1

Browse files
authored
Merge pull request #6919 from radarhere/tiff
Moved tests that require libtiff
2 parents 28b8b60 + 2fc7cfb commit 28c89b1

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

Tests/test_file_libtiff.py

+48
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,36 @@ def test_open_missing_samplesperpixel(self):
984984
) as im:
985985
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
986986

987+
@pytest.mark.parametrize(
988+
"file_name, mode, size, tile",
989+
[
990+
(
991+
"tiff_wrong_bits_per_sample.tiff",
992+
"RGBA",
993+
(52, 53),
994+
[("raw", (0, 0, 52, 53), 160, ("RGBA", 0, 1))],
995+
),
996+
(
997+
"tiff_wrong_bits_per_sample_2.tiff",
998+
"RGB",
999+
(16, 16),
1000+
[("raw", (0, 0, 16, 16), 8, ("RGB", 0, 1))],
1001+
),
1002+
(
1003+
"tiff_wrong_bits_per_sample_3.tiff",
1004+
"RGBA",
1005+
(512, 256),
1006+
[("libtiff", (0, 0, 512, 256), 0, ("RGBA", "tiff_lzw", False, 48782))],
1007+
),
1008+
],
1009+
)
1010+
def test_wrong_bits_per_sample(self, file_name, mode, size, tile):
1011+
with Image.open("Tests/images/" + file_name) as im:
1012+
assert im.mode == mode
1013+
assert im.size == size
1014+
assert im.tile == tile
1015+
im.load()
1016+
9871017
def test_no_rows_per_strip(self):
9881018
# This image does not have a RowsPerStrip TIFF tag
9891019
infile = "Tests/images/no_rows_per_strip.tif"
@@ -1071,3 +1101,21 @@ def test_save_many_compressed(self, tmp_path):
10711101
out = str(tmp_path / "temp.tif")
10721102
for _ in range(10000):
10731103
im.save(out, compression="jpeg")
1104+
1105+
@pytest.mark.parametrize(
1106+
"path, sizes",
1107+
(
1108+
("Tests/images/hopper.tif", ()),
1109+
("Tests/images/child_ifd.tiff", (16, 8)),
1110+
("Tests/images/child_ifd_jpeg.tiff", (20,)),
1111+
),
1112+
)
1113+
def test_get_child_images(self, path, sizes):
1114+
with Image.open(path) as im:
1115+
ims = im.get_child_images()
1116+
1117+
assert len(ims) == len(sizes)
1118+
for i, im in enumerate(ims):
1119+
w = sizes[i]
1120+
expected = Image.new("RGB", (w, w), "#f00")
1121+
assert_image_similar(im, expected, 1)

Tests/test_file_tiff.py

-48
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,6 @@ def test_context_manager(self):
8484
with Image.open("Tests/images/multipage.tiff") as im:
8585
im.load()
8686

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:
97-
ims = im.get_child_images()
98-
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)
104-
10587
def test_mac_tiff(self):
10688
# Read RGBa images from macOS [@PIL136]
10789

@@ -118,36 +100,6 @@ def test_bigtiff(self):
118100
with Image.open("Tests/images/hopper_bigtiff.tif") as im:
119101
assert_image_equal_tofile(im, "Tests/images/hopper.tif")
120102

121-
@pytest.mark.parametrize(
122-
"file_name,mode,size,tile",
123-
[
124-
(
125-
"tiff_wrong_bits_per_sample.tiff",
126-
"RGBA",
127-
(52, 53),
128-
[("raw", (0, 0, 52, 53), 160, ("RGBA", 0, 1))],
129-
),
130-
(
131-
"tiff_wrong_bits_per_sample_2.tiff",
132-
"RGB",
133-
(16, 16),
134-
[("raw", (0, 0, 16, 16), 8, ("RGB", 0, 1))],
135-
),
136-
(
137-
"tiff_wrong_bits_per_sample_3.tiff",
138-
"RGBA",
139-
(512, 256),
140-
[("libtiff", (0, 0, 512, 256), 0, ("RGBA", "tiff_lzw", False, 48782))],
141-
),
142-
],
143-
)
144-
def test_wrong_bits_per_sample(self, file_name, mode, size, tile):
145-
with Image.open("Tests/images/" + file_name) as im:
146-
assert im.mode == mode
147-
assert im.size == size
148-
assert im.tile == tile
149-
im.load()
150-
151103
def test_set_legacy_api(self):
152104
ifd = TiffImagePlugin.ImageFileDirectory_v2()
153105
with pytest.raises(Exception) as e:

0 commit comments

Comments
 (0)