diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 9267fb567..2b577b36f 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -338,14 +338,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():