Skip to content

Commit

Permalink
Merge pull request #2428 from hugovk/test-pixar
Browse files Browse the repository at this point in the history
Test PixarImageFile for correctness
  • Loading branch information
wiredfool committed Feb 28, 2017
2 parents 5777fa9 + 49815f8 commit e824aa4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions PIL/PixarImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

__version__ = "0.1"


#
# helpers

Expand Down Expand Up @@ -61,6 +62,7 @@ def _open(self):
# create tile descriptor (assuming "dumped")
self.tile = [("raw", (0, 0)+self.size, 1024, (self.mode, 0, 1))]


#
# --------------------------------------------------------------------

Expand Down
Binary file added Tests/images/hopper.pxr
Binary file not shown.
30 changes: 30 additions & 0 deletions Tests/test_file_pixar.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit e824aa4

Please sign in to comment.