Skip to content

Commit a9d05a1

Browse files
authored
Fixed unclosed file warnings (#8705)
Co-authored-by: Andrew Murray <[email protected]>
1 parent e19a149 commit a9d05a1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Tests/test_file_libtiff.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1103,13 +1103,15 @@ def test_exif_transpose(self) -> None:
11031103
)
11041104
def test_buffering(self, test_file: str) -> None:
11051105
# load exif first
1106-
with Image.open(open(test_file, "rb", buffering=1048576)) as im:
1107-
exif = dict(im.getexif())
1106+
with open(test_file, "rb", buffering=1048576) as f:
1107+
with Image.open(f) as im:
1108+
exif = dict(im.getexif())
11081109

11091110
# load image before exif
1110-
with Image.open(open(test_file, "rb", buffering=1048576)) as im2:
1111-
im2.load()
1112-
exif_after_load = dict(im2.getexif())
1111+
with open(test_file, "rb", buffering=1048576) as f:
1112+
with Image.open(f) as im2:
1113+
im2.load()
1114+
exif_after_load = dict(im2.getexif())
11131115

11141116
assert exif == exif_after_load
11151117

0 commit comments

Comments
 (0)