Merge pull request #1 from radarhere/truncated

Test error is raised without LOAD_TRUNCATED_IMAGES
This commit is contained in:
FangFuxin 2024-01-16 16:10:11 +08:00 committed by GitHub
commit 6c55dff8af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -778,11 +778,15 @@ class TestFilePng:
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