Skip to content

Commit

Permalink
Merge pull request #1 from radarhere/truncated
Browse files Browse the repository at this point in the history
Test error is raised without LOAD_TRUNCATED_IMAGES
  • Loading branch information
lajiyuan authored Jan 16, 2024
2 parents b2711c3 + 62e6d62 commit 6c55dff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
File renamed without changes
10 changes: 7 additions & 3 deletions Tests/test_file_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,15 @@ 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:
assert_image_equal_tofile(im, "Tests/images/end_trunc_file.png")
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 6c55dff

Please sign in to comment.