Pillow/Tests/test_file_sgi.py

51 lines
1.5 KiB
Python
Raw Normal View History

from helper import unittest, PillowTestCase, hopper
2014-07-16 22:28:17 +04:00
2015-07-03 08:03:25 +03:00
from PIL import Image, SgiImagePlugin
2014-07-16 22:28:17 +04:00
class TestFileSgi(PillowTestCase):
def test_rgb(self):
# Created with ImageMagick then renamed:
# convert hopper.ppm -compress None sgi:hopper.rgb
test_file = "Tests/images/hopper.rgb"
2014-07-16 22:28:17 +04:00
im = Image.open(test_file)
self.assert_image_equal(im, hopper())
2014-07-16 22:28:17 +04:00
def test_l(self):
# Created with ImageMagick
# convert hopper.ppm -monochrome -compress None sgi:hopper.bw
test_file = "Tests/images/hopper.bw"
2014-07-16 22:28:17 +04:00
im = Image.open(test_file)
self.assert_image_similar(im, hopper('L'), 2)
2014-07-16 22:28:17 +04:00
def test_rgba(self):
# Created with ImageMagick:
# convert transparent.png -compress None transparent.sgi
2014-07-16 22:28:17 +04:00
test_file = "Tests/images/transparent.sgi"
im = Image.open(test_file)
target = Image.open('Tests/images/transparent.png')
self.assert_image_equal(im, target)
def test_rle(self):
# convert hopper.ppm hopper.sgi
# We don't support RLE compression, this should throw a value error
test_file = "Tests/images/hopper.sgi"
with self.assertRaises(ValueError):
Image.open(test_file)
2014-07-16 22:28:17 +04:00
2015-07-03 08:03:25 +03:00
def test_invalid_file(self):
2015-07-03 09:22:56 +03:00
invalid_file = "Tests/images/flower.jpg"
self.assertRaises(ValueError,
lambda:
SgiImagePlugin.SgiImageFile(invalid_file))
2015-07-03 08:03:25 +03:00
2014-07-16 22:28:17 +04:00
if __name__ == '__main__':
unittest.main()