Test MicImagePlugin for correctness

This commit is contained in:
Hugo 2017-03-13 08:18:13 +02:00
parent 92c32ccf37
commit b7d14b04b6
2 changed files with 39 additions and 2 deletions

View File

@ -96,6 +96,7 @@ class MicImageFile(TiffImagePlugin.TiffImageFile):
return self.frame
#
# --------------------------------------------------------------------

View File

@ -1,10 +1,46 @@
from helper import unittest, PillowTestCase
from helper import unittest, PillowTestCase, hopper
from PIL import MicImagePlugin
from PIL import Image, MicImagePlugin
TEST_FILE = "Tests/images/hopper.mic"
class TestFileMic(PillowTestCase):
def test_sanity(self):
im = Image.open(TEST_FILE)
im.load()
self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (128, 128))
self.assertEqual(im.format, "MIC")
im2 = hopper("RGBA")
self.assert_image_similar(im, im2, 123.5)
def test_n_frames(self):
im = Image.open(TEST_FILE)
self.assertEqual(im.n_frames, 1)
def test_is_animated(self):
im = Image.open(TEST_FILE)
self.assertFalse(im.is_animated)
def test_tell(self):
im = Image.open(TEST_FILE)
self.assertEqual(im.tell(), 0)
def test_seek(self):
im = Image.open(TEST_FILE)
im.seek(0)
self.assertEqual(im.tell(), 0)
self.assertRaises(EOFError, lambda: im.seek(99))
self.assertEqual(im.tell(), 0)
def test_invalid_file(self):
# Test an invalid OLE file
invalid_file = "Tests/images/flower.jpg"