mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #2428 from hugovk/test-pixar
Test PixarImageFile for correctness
This commit is contained in:
commit
e824aa4e86
|
@ -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
BIN
Tests/images/hopper.pxr
Normal file
Binary file not shown.
30
Tests/test_file_pixar.py
Normal file
30
Tests/test_file_pixar.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user