@@ -303,11 +303,11 @@ def test_apng_chunk_errors() -> None:
303
303
assert isinstance (im , PngImagePlugin .PngImageFile )
304
304
assert not im .is_animated
305
305
306
- with pytest .warns (UserWarning , match = "Invalid APNG" ): # noqa: PT031
307
- with Image .open ("Tests/images/apng/chunk_multi_actl.png" ) as im :
308
- im . load ( )
309
- assert isinstance ( im , PngImagePlugin . PngImageFile )
310
- assert not im .is_animated
306
+ with pytest .warns (UserWarning , match = "Invalid APNG" ):
307
+ im = Image .open ("Tests/images/apng/chunk_multi_actl.png" )
308
+ assert isinstance ( im , PngImagePlugin . PngImageFile )
309
+ assert not im . is_animated
310
+ im .close ()
311
311
312
312
with Image .open ("Tests/images/apng/chunk_actl_after_idat.png" ) as im :
313
313
assert isinstance (im , PngImagePlugin .PngImageFile )
@@ -330,18 +330,20 @@ def test_apng_chunk_errors() -> None:
330
330
331
331
332
332
def test_apng_syntax_errors () -> None :
333
- with pytest .warns (UserWarning , match = "Invalid APNG" ): # noqa: PT031
334
- with Image .open ("Tests/images/apng/syntax_num_frames_zero.png" ) as im :
335
- assert isinstance (im , PngImagePlugin .PngImageFile )
336
- assert not im .is_animated
337
- with pytest .raises (OSError ):
338
- im .load ()
333
+ with pytest .warns (UserWarning , match = "Invalid APNG" ):
334
+ im = Image .open ("Tests/images/apng/syntax_num_frames_zero.png" )
335
+ assert isinstance (im , PngImagePlugin .PngImageFile )
336
+ assert not im .is_animated
337
+ with pytest .raises (OSError ):
338
+ im .load ()
339
+ im .close ()
339
340
340
- with pytest .warns (UserWarning , match = "Invalid APNG" ): # noqa: PT031
341
- with Image .open ("Tests/images/apng/syntax_num_frames_zero_default.png" ) as im :
342
- assert isinstance (im , PngImagePlugin .PngImageFile )
343
- assert not im .is_animated
344
- im .load ()
341
+ with pytest .warns (UserWarning , match = "Invalid APNG" ):
342
+ im = Image .open ("Tests/images/apng/syntax_num_frames_zero_default.png" )
343
+ assert isinstance (im , PngImagePlugin .PngImageFile )
344
+ assert not im .is_animated
345
+ im .load ()
346
+ im .close ()
345
347
346
348
# we can handle this case gracefully
347
349
with Image .open ("Tests/images/apng/syntax_num_frames_low.png" ) as im :
@@ -354,11 +356,12 @@ def test_apng_syntax_errors() -> None:
354
356
im .seek (im .n_frames - 1 )
355
357
im .load ()
356
358
357
- with pytest .warns (UserWarning , match = "Invalid APNG" ): # noqa: PT031
358
- with Image .open ("Tests/images/apng/syntax_num_frames_invalid.png" ) as im :
359
- assert isinstance (im , PngImagePlugin .PngImageFile )
360
- assert not im .is_animated
361
- im .load ()
359
+ with pytest .warns (UserWarning , match = "Invalid APNG" ):
360
+ im = Image .open ("Tests/images/apng/syntax_num_frames_invalid.png" )
361
+ assert isinstance (im , PngImagePlugin .PngImageFile )
362
+ assert not im .is_animated
363
+ im .load ()
364
+ im .close ()
362
365
363
366
364
367
@pytest .mark .parametrize (
0 commit comments