Skip to content

Commit 3111e37

Browse files
authored
Merge pull request #8679 from radarhere/test
2 parents bce6097 + 15ade68 commit 3111e37

File tree

6 files changed

+6
-33
lines changed

6 files changed

+6
-33
lines changed

Tests/helper.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,11 @@ def assert_image_similar_tofile(
140140
filename: str,
141141
epsilon: float,
142142
msg: str | None = None,
143-
mode: str | None = None,
144143
) -> None:
145144
with Image.open(filename) as img:
146-
if mode:
147-
img = img.convert(mode)
148145
assert_image_similar(a, img, epsilon, msg)
149146

150147

151-
def assert_all_same(items: Sequence[Any], msg: str | None = None) -> None:
152-
assert items.count(items[0]) == len(items), msg
153-
154-
155148
def assert_not_all_same(items: Sequence[Any], msg: str | None = None) -> None:
156149
assert items.count(items[0]) != len(items), msg
157150

Tests/test_file_apng.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,8 @@ def test_apng_syntax_errors() -> None:
307307
im.load()
308308

309309
# we can handle this case gracefully
310-
exception = None
311310
with Image.open("Tests/images/apng/syntax_num_frames_low.png") as im:
312-
try:
313-
im.seek(im.n_frames - 1)
314-
except Exception as e:
315-
exception = e
316-
assert exception is None
311+
im.seek(im.n_frames - 1)
317312

318313
with pytest.raises(OSError):
319314
with Image.open("Tests/images/apng/syntax_num_frames_high.png") as im:
@@ -405,13 +400,8 @@ def test_apng_save_split_fdat(tmp_path: Path) -> None:
405400
append_images=frames,
406401
)
407402
with Image.open(test_file) as im:
408-
exception = None
409-
try:
410-
im.seek(im.n_frames - 1)
411-
im.load()
412-
except Exception as e:
413-
exception = e
414-
assert exception is None
403+
im.seek(im.n_frames - 1)
404+
im.load()
415405

416406

417407
def test_apng_save_duration_loop(tmp_path: Path) -> None:

Tests/test_file_iptc.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ def test_getiptcinfo_fotostation() -> None:
5858

5959
# Assert
6060
assert iptc is not None
61-
for tag in iptc.keys():
62-
if tag[0] == 240:
63-
return
64-
pytest.fail("FotoStation tag not found")
61+
assert 240 in (tag[0] for tag in iptc.keys()), "FotoStation tag not found"
6562

6663

6764
def test_getiptcinfo_zero_padding() -> None:

Tests/test_file_jpeg2k.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ def test_plt_marker(card: ImageFile.ImageFile) -> None:
492492
out.seek(0)
493493
while True:
494494
marker = out.read(2)
495-
if not marker:
496-
pytest.fail("End of stream without PLT")
495+
assert marker, "End of stream without PLT"
497496

498497
jp2_boxid = _binary.i16be(marker)
499498
if jp2_boxid == 0xFF4F:

Tests/test_file_libtiff.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ def _assert_noerr(self, tmp_path: Path, im: TiffImagePlugin.TiffImageFile) -> No
3636
im.load()
3737
im.getdata()
3838

39-
try:
40-
assert im._compression == "group4"
41-
except AttributeError:
42-
print("No _compression")
43-
print(dir(im))
39+
assert im._compression == "group4"
4440

4541
# can we write it back out, in a different form.
4642
out = str(tmp_path / "temp.png")

Tests/test_image.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ def test_pathlib(self, tmp_path: Path) -> None:
189189
if ext == ".jp2" and not features.check_codec("jpg_2000"):
190190
pytest.skip("jpg_2000 not available")
191191
temp_file = str(tmp_path / ("temp." + ext))
192-
if os.path.exists(temp_file):
193-
os.remove(temp_file)
194192
im.save(Path(temp_file))
195193

196194
def test_fp_name(self, tmp_path: Path) -> None:

0 commit comments

Comments
 (0)