diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index e6da7bb8b..367e57c14 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -370,7 +370,8 @@ class TestFileJpeg(PillowTestCase): # Act # Shouldn't raise error - im = Image.open("Tests/images/sugarshack_bad_mpo_header.jpg") + fn = "Tests/images/sugarshack_bad_mpo_header.jpg" + im = self.assert_warning(UserWarning, lambda: Image.open(fn)) # Assert self.assertEqual(im.format, "JPEG") diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index f8ce199da..a221f15cc 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -103,8 +103,9 @@ class TestFileTiff(PillowTestCase): lambda: TiffImagePlugin.TiffImageFile(invalid_file)) def test_bad_exif(self): + i = Image.open('Tests/images/hopper_bad_exif.jpg') try: - Image.open('Tests/images/hopper_bad_exif.jpg')._getexif() + self.assert_warning(UserWarning, lambda: i._getexif()) except struct.error: self.fail( "Bad EXIF data passed incorrect values to _binary unpack")