Image.core.open_ppm has been removed. Test the Storage.c fix with an alternate method. Assert that the ordinary opener rejects the negative size in the PPM file

This commit is contained in:
wiredfool 2016-10-03 03:50:25 -07:00
parent 445451c0b9
commit b3ad80a2bd
2 changed files with 18 additions and 8 deletions

View File

@ -45,15 +45,13 @@ class TestFilePpm(PillowTestCase):
def test_neg_ppm(self):
"""test_neg_ppm
# Storage.c accepted negative values for xsize, ysize. the
# internal open_ppm function didn't check for sanity but it
# has been removed. The default opener doesn't accept negative
# sizes.
Storage.c accepted negative values for xsize, ysize.
open_ppm is a core debugging item that doesn't check any parameters for
sanity.
"""
with self.assertRaises(ValueError):
Image.core.open_ppm('Tests/images/negative_size.ppm')
with self.assertRaises(IOError):
Image.open('Tests/images/negative_size.ppm')
if __name__ == '__main__':

View File

@ -248,6 +248,18 @@ class TestImage(PillowTestCase):
self.assertTrue(Image.new('RGB', (1,1)))
def test_storage_neg(self):
# Storage.c accepted negative values for xsize, ysize. Was
# test_neg_ppm, but the core function for that has been
# removed Calling directly into core to test the error in
# Storage.c, rather than the size check above
with self.assertRaises(ValueError):
Image.core.fill('RGB', (2,-2), (0,0,0))
if __name__ == '__main__':
unittest.main()