Test pixar for similarity

This commit is contained in:
Hugo 2017-02-28 08:27:53 +02:00
parent c9e139e260
commit 49815f8d4a
2 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))]
#
# --------------------------------------------------------------------

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()