@@ -334,8 +334,10 @@ def test_exif_gps(self, tmp_path: Path) -> None:
334
334
335
335
# Reading
336
336
with Image .open ("Tests/images/exif_gps.jpg" ) as im :
337
- exif = im ._getexif ()
338
- assert exif [gps_index ] == expected_exif_gps
337
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
338
+ exif_data = im ._getexif ()
339
+ assert exif_data is not None
340
+ assert exif_data [gps_index ] == expected_exif_gps
339
341
340
342
# Writing
341
343
f = tmp_path / "temp.jpg"
@@ -344,8 +346,10 @@ def test_exif_gps(self, tmp_path: Path) -> None:
344
346
hopper ().save (f , exif = exif )
345
347
346
348
with Image .open (f ) as reloaded :
347
- exif = reloaded ._getexif ()
348
- assert exif [gps_index ] == expected_exif_gps
349
+ assert isinstance (reloaded , JpegImagePlugin .JpegImageFile )
350
+ exif_data = reloaded ._getexif ()
351
+ assert exif_data is not None
352
+ assert exif_data [gps_index ] == expected_exif_gps
349
353
350
354
def test_empty_exif_gps (self ) -> None :
351
355
with Image .open ("Tests/images/empty_gps_ifd.jpg" ) as im :
@@ -372,6 +376,7 @@ def test_exif_equality(self) -> None:
372
376
exifs = []
373
377
for i in range (2 ):
374
378
with Image .open ("Tests/images/exif-200dpcm.jpg" ) as im :
379
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
375
380
exifs .append (im ._getexif ())
376
381
assert exifs [0 ] == exifs [1 ]
377
382
@@ -405,13 +410,17 @@ def test_exif_rollback(self) -> None:
405
410
}
406
411
407
412
with Image .open ("Tests/images/exif_gps.jpg" ) as im :
413
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
408
414
exif = im ._getexif ()
415
+ assert exif is not None
409
416
410
417
for tag , value in expected_exif .items ():
411
418
assert value == exif [tag ]
412
419
413
420
def test_exif_gps_typeerror (self ) -> None :
414
421
with Image .open ("Tests/images/exif_gps_typeerror.jpg" ) as im :
422
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
423
+
415
424
# Should not raise a TypeError
416
425
im ._getexif ()
417
426
@@ -491,7 +500,9 @@ def getsampling(
491
500
492
501
def test_exif (self ) -> None :
493
502
with Image .open ("Tests/images/pil_sample_rgb.jpg" ) as im :
503
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
494
504
info = im ._getexif ()
505
+ assert info is not None
495
506
assert info [305 ] == "Adobe Photoshop CS Macintosh"
496
507
497
508
def test_get_child_images (self ) -> None :
@@ -676,11 +687,13 @@ def test_load_16bit_qtables(self) -> None:
676
687
677
688
def test_save_multiple_16bit_qtables (self ) -> None :
678
689
with Image .open ("Tests/images/hopper_16bit_qtables.jpg" ) as im :
690
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
679
691
im2 = self .roundtrip (im , qtables = "keep" )
680
692
assert im .quantization == im2 .quantization
681
693
682
694
def test_save_single_16bit_qtable (self ) -> None :
683
695
with Image .open ("Tests/images/hopper_16bit_qtables.jpg" ) as im :
696
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
684
697
im2 = self .roundtrip (im , qtables = {0 : im .quantization [0 ]})
685
698
assert len (im2 .quantization ) == 1
686
699
assert im2 .quantization [0 ] == im .quantization [0 ]
@@ -889,7 +902,10 @@ def test_ifd_offset_exif(self) -> None:
889
902
# in contrast to normal 8
890
903
with Image .open ("Tests/images/exif-ifd-offset.jpg" ) as im :
891
904
# Act / Assert
892
- assert im ._getexif ()[306 ] == "2017:03:13 23:03:09"
905
+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
906
+ exif = im ._getexif ()
907
+ assert exif is not None
908
+ assert exif [306 ] == "2017:03:13 23:03:09"
893
909
894
910
def test_multiple_exif (self ) -> None :
895
911
with Image .open ("Tests/images/multiple_exif.jpg" ) as im :
0 commit comments