From 8bfd763f339fb8d043131e86552d816cb112cd46 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 25 Jun 2021 23:16:46 +1000 Subject: [PATCH] Use context manager --- Tests/test_file_gif.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 420c498ed..b2dfecf7b 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -332,14 +332,13 @@ def test_dispose_background(): def test_transparent_dispose(): - img = Image.open("Tests/images/transparent_dispose.gif") - expected_colors = [(2, 1, 2), (0, 1, 0), (2, 1, 2)] - for frame in range(3): - img.seek(frame) - for x in range(3): - color = img.getpixel((x, 0)) - assert color == expected_colors[frame][x] + with Image.open("Tests/images/transparent_dispose.gif") as img: + for frame in range(3): + img.seek(frame) + for x in range(3): + color = img.getpixel((x, 0)) + assert color == expected_colors[frame][x] def test_dispose_previous():