Use context manager

This commit is contained in:
Andrew Murray 2021-06-25 23:16:46 +10:00
parent 432677740d
commit f6d504c8f6

View File

@ -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():