Fixed unclosed file warnings

This commit is contained in:
Andrew Murray 2025-01-19 22:43:35 +11:00
parent cf7dd2f0e9
commit 2c0fe60a20

View File

@ -1103,13 +1103,15 @@ class TestFileLibTiff(LibTiffTestCase):
)
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())
with open(test_file, "rb", buffering=1048576) as f:
with Image.open(f) 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())
with open(test_file, "rb", buffering=1048576) as f:
with Image.open(f) as im2:
im2.load()
exif_after_load = dict(im2.getexif())
assert exif == exif_after_load