Merge pull request #1 from radarhere/tom/bufferedio

Moved test
This commit is contained in:
Tom Flanagan 2024-11-20 05:22:49 -08:00 committed by GitHub
commit 9fd4450281
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 25 deletions

View File

@ -1098,6 +1098,25 @@ class TestFileLibTiff(LibTiffTestCase):
assert_image_similar(base_im, im, 0.7) assert_image_similar(base_im, im, 0.7)
@pytest.mark.parametrize(
"test_file",
[
"Tests/images/old-style-jpeg-compression-no-samplesperpixel.tif",
"Tests/images/old-style-jpeg-compression.tif",
],
)
def test_buffering(self, test_file: str) -> None:
# load exif first
with Image.open(open(test_file, "rb", buffering=1048576)) as im:
exif = dict(im.getexif())
# load image before exif
with Image.open(open(test_file, "rb", buffering=1048576)) as im2:
im2.load()
exif_after_load = dict(im2.getexif())
assert exif == exif_after_load
@pytest.mark.valgrind_known_error(reason="Backtrace in Python Core") @pytest.mark.valgrind_known_error(reason="Backtrace in Python Core")
def test_sampleformat_not_corrupted(self) -> None: def test_sampleformat_not_corrupted(self) -> None:
# Assert that a TIFF image with SampleFormat=UINT tag is not corrupted # Assert that a TIFF image with SampleFormat=UINT tag is not corrupted

View File

@ -1,25 +0,0 @@
from __future__ import annotations
import pytest
from PIL import Image
@pytest.mark.parametrize(
"test_file",
[
"Tests/images/old-style-jpeg-compression-no-samplesperpixel.tif",
"Tests/images/old-style-jpeg-compression.tif",
],
)
def test_libtiff_exif_loading(test_file) -> None:
# loading image before exif
im1 = Image.open(open(test_file, "rb", buffering=1048576))
im1.load()
exif1 = dict(im1.getexif())
# loading exif before image
im2 = Image.open(open(test_file, "rb", buffering=1048576))
exif2 = dict(im2.getexif())
assert exif1 == exif2