2014-07-16 22:28:17 +04:00
|
|
|
from helper import unittest, PillowTestCase
|
|
|
|
|
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):
|
|
|
|
# Arrange
|
|
|
|
# Created with ImageMagick then renamed:
|
2014-09-04 11:31:16 +04:00
|
|
|
# convert hopper.ppm hopper.sgi
|
|
|
|
test_file = "Tests/images/hopper.rgb"
|
2014-07-16 22:28:17 +04:00
|
|
|
|
|
|
|
# Act / Assert
|
2014-07-20 02:50:05 +04:00
|
|
|
self.assertRaises(ValueError, lambda: Image.open(test_file))
|
2014-07-16 22:28:17 +04:00
|
|
|
|
|
|
|
def test_l(self):
|
|
|
|
# Arrange
|
|
|
|
# Created with ImageMagick then renamed:
|
2014-09-04 11:31:16 +04:00
|
|
|
# convert hopper.ppm -monochrome hopper.sgi
|
|
|
|
test_file = "Tests/images/hopper.bw"
|
2014-07-16 22:28:17 +04:00
|
|
|
|
|
|
|
# Act / Assert
|
2014-07-20 02:50:05 +04:00
|
|
|
self.assertRaises(ValueError, lambda: Image.open(test_file))
|
2014-07-16 22:28:17 +04:00
|
|
|
|
|
|
|
def test_rgba(self):
|
|
|
|
# Arrange
|
|
|
|
# Created with ImageMagick:
|
|
|
|
# convert transparent.png transparent.sgi
|
|
|
|
test_file = "Tests/images/transparent.sgi"
|
|
|
|
|
|
|
|
# Act / Assert
|
2014-07-20 02:50:05 +04:00
|
|
|
self.assertRaises(ValueError, lambda: 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()
|