Skip to content

Commit 7653280

Browse files
committed
Fix ResourceWarning in selftest.py
1 parent 3332c1d commit 7653280

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

selftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ def testimage() -> None:
4040
>>> with Image.open("Tests/images/hopper.gif") as im:
4141
... _info(im)
4242
('GIF', 'P', (128, 128))
43-
>>> _info(Image.open("Tests/images/hopper.ppm"))
43+
>>> with Image.open("Tests/images/hopper.ppm") as im:
44+
... _info(im)
4445
('PPM', 'RGB', (128, 128))
4546
>>> try:
46-
... _info(Image.open("Tests/images/hopper.jpg"))
47+
... with Image.open("Tests/images/hopper.jpg") as im:
48+
... _info(im)
4749
... except OSError as v:
48-
... print(v)
50+
... print(v)
4951
('JPEG', 'RGB', (128, 128))
5052
5153
PIL doesn't actually load the image data until it's needed,

0 commit comments

Comments
 (0)