From a9d05a1e5122f1bab86d9c4d1b34a9cd40093d51 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Tue, 28 Jan 2025 07:59:44 +1100 Subject: [PATCH] Fixed unclosed file warnings (#8705) Co-authored-by: Andrew Murray --- Tests/test_file_libtiff.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index a5715db1b5f..0332947106a 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -1103,13 +1103,15 @@ def test_exif_transpose(self) -> None: ) 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