@@ -330,8 +330,10 @@ def test_exif_gps(self, tmp_path: Path) -> None:
330
330
331
331
# Reading
332
332
with Image .open ("Tests/images/exif_gps.jpg" ) as im :
333
- exif = im ._getexif ()
334
- assert exif [gps_index ] == expected_exif_gps
333
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
334
+ exif_data = im ._getexif ()
335
+ assert exif_data is not None
336
+ assert exif_data [gps_index ] == expected_exif_gps
335
337
336
338
# Writing
337
339
f = tmp_path / "temp.jpg"
@@ -340,8 +342,10 @@ def test_exif_gps(self, tmp_path: Path) -> None:
340
342
hopper ().save (f , exif = exif )
341
343
342
344
with Image .open (f ) as reloaded :
343
- exif = reloaded ._getexif ()
344
- assert exif [gps_index ] == expected_exif_gps
345
+ assert isinstance (reloaded , JpegImagePlugin .JpegImageFile )
346
+ exif_data = reloaded ._getexif ()
347
+ assert exif_data is not None
348
+ assert exif_data [gps_index ] == expected_exif_gps
345
349
346
350
def test_empty_exif_gps (self ) -> None :
347
351
with Image .open ("Tests/images/empty_gps_ifd.jpg" ) as im :
@@ -368,6 +372,7 @@ def test_exif_equality(self) -> None:
368
372
exifs = []
369
373
for i in range (2 ):
370
374
with Image .open ("Tests/images/exif-200dpcm.jpg" ) as im :
375
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
371
376
exifs .append (im ._getexif ())
372
377
assert exifs [0 ] == exifs [1 ]
373
378
@@ -401,13 +406,17 @@ def test_exif_rollback(self) -> None:
401
406
}
402
407
403
408
with Image .open ("Tests/images/exif_gps.jpg" ) as im :
409
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
404
410
exif = im ._getexif ()
411
+ assert exif is not None
405
412
406
413
for tag , value in expected_exif .items ():
407
414
assert value == exif [tag ]
408
415
409
416
def test_exif_gps_typeerror (self ) -> None :
410
417
with Image .open ("Tests/images/exif_gps_typeerror.jpg" ) as im :
418
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
419
+
411
420
# Should not raise a TypeError
412
421
im ._getexif ()
413
422
@@ -487,7 +496,9 @@ def getsampling(
487
496
488
497
def test_exif (self ) -> None :
489
498
with Image .open ("Tests/images/pil_sample_rgb.jpg" ) as im :
499
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
490
500
info = im ._getexif ()
501
+ assert info is not None
491
502
assert info [305 ] == "Adobe Photoshop CS Macintosh"
492
503
493
504
def test_get_child_images (self ) -> None :
@@ -690,11 +701,13 @@ def test_load_16bit_qtables(self) -> None:
690
701
691
702
def test_save_multiple_16bit_qtables (self ) -> None :
692
703
with Image .open ("Tests/images/hopper_16bit_qtables.jpg" ) as im :
704
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
693
705
im2 = self .roundtrip (im , qtables = "keep" )
694
706
assert im .quantization == im2 .quantization
695
707
696
708
def test_save_single_16bit_qtable (self ) -> None :
697
709
with Image .open ("Tests/images/hopper_16bit_qtables.jpg" ) as im :
710
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
698
711
im2 = self .roundtrip (im , qtables = {0 : im .quantization [0 ]})
699
712
assert len (im2 .quantization ) == 1
700
713
assert im2 .quantization [0 ] == im .quantization [0 ]
@@ -898,7 +911,10 @@ def test_ifd_offset_exif(self) -> None:
898
911
# in contrast to normal 8
899
912
with Image .open ("Tests/images/exif-ifd-offset.jpg" ) as im :
900
913
# Act / Assert
901
- assert im ._getexif ()[306 ] == "2017:03:13 23:03:09"
914
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
915
+ exif = im ._getexif ()
916
+ assert exif is not None
917
+ assert exif [306 ] == "2017:03:13 23:03:09"
902
918
903
919
def test_multiple_exif (self ) -> None :
904
920
with Image .open ("Tests/images/multiple_exif.jpg" ) as im :
0 commit comments