mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 16:52:29 +03:00
More tests for MspImagePlugin.py
This commit is contained in:
parent
45a616ef80
commit
3bbfcb23aa
|
@ -191,11 +191,11 @@ def hopper(mode="RGB", cache={}):
|
||||||
if mode == "RGB":
|
if mode == "RGB":
|
||||||
im = Image.open("Tests/images/hopper.ppm")
|
im = Image.open("Tests/images/hopper.ppm")
|
||||||
elif mode == "F":
|
elif mode == "F":
|
||||||
im = lena("L").convert(mode)
|
im = hopper("L").convert(mode)
|
||||||
elif mode[:4] == "I;16":
|
elif mode[:4] == "I;16":
|
||||||
im = lena("I").convert(mode)
|
im = hopper("I").convert(mode)
|
||||||
else:
|
else:
|
||||||
im = lena("RGB").convert(mode)
|
im = hopper("RGB").convert(mode)
|
||||||
# cache[mode] = im
|
# cache[mode] = im
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
from helper import unittest, PillowTestCase, lena
|
from helper import unittest, PillowTestCase, hopper
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
TEST_FILE = "Tests/images/hopper.msp"
|
||||||
|
|
||||||
|
|
||||||
class TestFileMsp(PillowTestCase):
|
class TestFileMsp(PillowTestCase):
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
|
|
||||||
file = self.tempfile("temp.msp")
|
file = self.tempfile("temp.msp")
|
||||||
|
|
||||||
lena("1").save(file)
|
hopper("1").save(file)
|
||||||
|
|
||||||
im = Image.open(file)
|
im = Image.open(file)
|
||||||
im.load()
|
im.load()
|
||||||
|
@ -17,6 +18,23 @@ class TestFileMsp(PillowTestCase):
|
||||||
self.assertEqual(im.size, (128, 128))
|
self.assertEqual(im.size, (128, 128))
|
||||||
self.assertEqual(im.format, "MSP")
|
self.assertEqual(im.format, "MSP")
|
||||||
|
|
||||||
|
def test_open(self):
|
||||||
|
# Arrange
|
||||||
|
# Act
|
||||||
|
im = Image.open(TEST_FILE)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
self.assertEqual(im.size, (128, 128))
|
||||||
|
self.assert_image_similar(im, hopper("1"), 4)
|
||||||
|
|
||||||
|
def test_cannot_save_save_wrong_mode(self):
|
||||||
|
# Arrange
|
||||||
|
im = hopper()
|
||||||
|
file = self.tempfile("temp.msp")
|
||||||
|
|
||||||
|
# Act/Assert
|
||||||
|
self.assertRaises(IOError, lambda: im.save(file))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user