Skip to content

Commit 246384d

Browse files
fdintinoradarhere
andcommitted
avif: Use Image.open context manager in tests
As per https://pillow.readthedocs.io/en/stable/releasenotes/7.0.0.html#image-del Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
1 parent 1ccea31 commit 246384d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Tests/test_file_avif.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ def test_no_resource_warning(self, tmp_path):
157157

158158
def test_file_pointer_could_be_reused(self):
159159
with open(TEST_AVIF_FILE, "rb") as blob:
160-
Image.open(blob).load()
161-
Image.open(blob).load()
160+
with Image.open(blob) as im:
161+
im.load()
162+
with Image.open(blob) as im:
163+
im.load()
162164

163165
def test_background_from_gif(self, tmp_path):
164166
with Image.open("Tests/images/chi.gif") as im:
@@ -170,7 +172,8 @@ def test_background_from_gif(self, tmp_path):
170172

171173
# Save as GIF
172174
out_gif = str(tmp_path / "temp.gif")
173-
Image.open(out_avif).save(out_gif)
175+
with Image.open(out_avif) as im:
176+
im.save(out_gif)
174177

175178
with Image.open(out_gif) as reread:
176179
reread_value = reread.convert("RGB").getpixel((1, 1))

0 commit comments

Comments
 (0)