Merge pull request #2428 from hugovk/test-pixar

Test PixarImageFile for correctness
This commit is contained in:
wiredfool 2017-02-28 10:33:38 +00:00 committed by GitHub
commit e824aa4e86
3 changed files with 32 additions and 0 deletions

View File

@ -24,6 +24,7 @@ from ._binary import i16le as i16
__version__ = "0.1"
#
# helpers
@ -61,6 +62,7 @@ class PixarImageFile(ImageFile.ImageFile):
# create tile descriptor (assuming "dumped")
self.tile = [("raw", (0, 0)+self.size, 1024, (self.mode, 0, 1))]
#
# --------------------------------------------------------------------

BIN
Tests/images/hopper.pxr Normal file

Binary file not shown.

30
Tests/test_file_pixar.py Normal file
View File

@ -0,0 +1,30 @@
from helper import hopper, unittest, PillowTestCase
from PIL import Image, PixarImagePlugin
# sample ppm stream
TEST_FILE = "Tests/images/hopper.pxr"
class TestImagePsd(PillowTestCase):
def test_sanity(self):
im = Image.open(TEST_FILE)
im.load()
self.assertEqual(im.mode, "RGB")
self.assertEqual(im.size, (128, 128))
self.assertEqual(im.format, "PIXAR")
im2 = hopper()
self.assert_image_similar(im, im2, 4.8)
def test_invalid_file(self):
invalid_file = "Tests/images/flower.jpg"
self.assertRaises(
SyntaxError,
lambda: PixarImagePlugin.PixarImageFile(invalid_file))
if __name__ == '__main__':
unittest.main()