mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Added correctness tests for opening SGI images
This commit is contained in:
parent
df5f62e719
commit
95888466c8
Binary file not shown.
Binary file not shown.
BIN
Tests/images/hopper.sgi
Normal file
BIN
Tests/images/hopper.sgi
Normal file
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
from helper import unittest, PillowTestCase
|
||||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image, SgiImagePlugin
|
||||
|
||||
|
@ -6,31 +6,37 @@ from PIL import Image, SgiImagePlugin
|
|||
class TestFileSgi(PillowTestCase):
|
||||
|
||||
def test_rgb(self):
|
||||
# Arrange
|
||||
# Created with ImageMagick then renamed:
|
||||
# convert hopper.ppm hopper.sgi
|
||||
# convert hopper.ppm -compress None sgi:hopper.rgb
|
||||
test_file = "Tests/images/hopper.rgb"
|
||||
|
||||
# Act / Assert
|
||||
self.assertRaises(ValueError, lambda: Image.open(test_file))
|
||||
im = Image.open(test_file)
|
||||
self.assert_image_equal(im, hopper())
|
||||
|
||||
def test_l(self):
|
||||
# Arrange
|
||||
# Created with ImageMagick then renamed:
|
||||
# convert hopper.ppm -monochrome hopper.sgi
|
||||
# Created with ImageMagick
|
||||
# convert hopper.ppm -monochrome -compress None sgi:hopper.bw
|
||||
test_file = "Tests/images/hopper.bw"
|
||||
|
||||
# Act / Assert
|
||||
self.assertRaises(ValueError, lambda: Image.open(test_file))
|
||||
im = Image.open(test_file)
|
||||
self.assert_image_similar(im, hopper('L'), 2)
|
||||
|
||||
def test_rgba(self):
|
||||
# Arrange
|
||||
# Created with ImageMagick:
|
||||
# convert transparent.png transparent.sgi
|
||||
# convert transparent.png -compress None transparent.sgi
|
||||
test_file = "Tests/images/transparent.sgi"
|
||||
|
||||
# Act / Assert
|
||||
self.assertRaises(ValueError, lambda: Image.open(test_file))
|
||||
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)
|
||||
|
||||
def test_invalid_file(self):
|
||||
invalid_file = "Tests/images/flower.jpg"
|
||||
|
|
Loading…
Reference in New Issue
Block a user