2016-11-20 06:43:43 +03:00
|
|
|
from helper import unittest, PillowTestCase, hopper
|
2014-07-16 15:24:23 +04:00
|
|
|
|
2015-07-03 08:03:25 +03:00
|
|
|
from PIL import Image, SunImagePlugin
|
2014-07-16 15:24:23 +04:00
|
|
|
|
|
|
|
|
|
|
|
class TestFileSun(PillowTestCase):
|
|
|
|
|
|
|
|
def test_sanity(self):
|
|
|
|
# Arrange
|
2014-09-04 13:59:03 +04:00
|
|
|
# Created with ImageMagick: convert hopper.jpg hopper.ras
|
|
|
|
test_file = "Tests/images/hopper.ras"
|
2014-07-16 15:24:23 +04:00
|
|
|
|
|
|
|
# Act
|
|
|
|
im = Image.open(test_file)
|
|
|
|
|
|
|
|
# Assert
|
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
|
|
|
2016-11-20 06:43:43 +03:00
|
|
|
self.assert_image_similar(im, hopper(), 5) # visually verified
|
|
|
|
|
2015-07-03 09:22:56 +03:00
|
|
|
invalid_file = "Tests/images/flower.jpg"
|
|
|
|
self.assertRaises(SyntaxError,
|
|
|
|
lambda: SunImagePlugin.SunImageFile(invalid_file))
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2016-11-20 06:12:30 +03:00
|
|
|
def test_im1(self):
|
|
|
|
im = Image.open('Tests/images/sunraster.im1')
|
|
|
|
target = Image.open('Tests/images/sunraster.im1.png')
|
|
|
|
self.assert_image_equal(im, target)
|
|
|
|
|
2014-07-16 15:24:23 +04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|