suppress and check warning during tests

This commit is contained in:
homm 2015-09-15 02:52:02 +03:00
parent 9930b05a33
commit 0f87b1f125
2 changed files with 4 additions and 2 deletions

View File

@ -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")

View File

@ -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")