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 # Act
# Shouldn't raise error # 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 # Assert
self.assertEqual(im.format, "JPEG") self.assertEqual(im.format, "JPEG")

View File

@ -103,8 +103,9 @@ class TestFileTiff(PillowTestCase):
lambda: TiffImagePlugin.TiffImageFile(invalid_file)) lambda: TiffImagePlugin.TiffImageFile(invalid_file))
def test_bad_exif(self): def test_bad_exif(self):
i = Image.open('Tests/images/hopper_bad_exif.jpg')
try: try:
Image.open('Tests/images/hopper_bad_exif.jpg')._getexif() self.assert_warning(UserWarning, lambda: i._getexif())
except struct.error: except struct.error:
self.fail( self.fail(
"Bad EXIF data passed incorrect values to _binary unpack") "Bad EXIF data passed incorrect values to _binary unpack")