Skip to content

Commit

Permalink
Test error is raised without LOAD_TRUNCATED_IMAGES
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 16, 2024
1 parent fe7b6d9 commit 62e6d62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
File renamed without changes
8 changes: 6 additions & 2 deletions Tests/test_file_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,14 @@ class MyStdOut:
with Image.open(mystdout) as reloaded:
assert_image_equal_tofile(reloaded, TEST_PNG_FILE)

def test_end_truncated_file(self):
def test_truncated_end_chunk(self):
with Image.open("Tests/images/truncated_end_chunk.png") as im:
with pytest.raises(OSError):
im.load()

ImageFile.LOAD_TRUNCATED_IMAGES = True
try:
with Image.open("Tests/images/end_trunc_file.png") as im:
with Image.open("Tests/images/truncated_end_chunk.png") as im:
assert_image_equal_tofile(im, "Tests/images/hopper.png")
finally:
ImageFile.LOAD_TRUNCATED_IMAGES = False
Expand Down

0 comments on commit 62e6d62

Please sign in to comment.