2014-09-18 15:48:07 +04:00
|
|
|
from helper import unittest, PillowTestCase, hopper
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
2014-09-18 15:48:07 +04:00
|
|
|
TEST_FILE = "Tests/images/hopper.msp"
|
|
|
|
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class TestFileMsp(PillowTestCase):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_sanity(self):
|
|
|
|
file = self.tempfile("temp.msp")
|
|
|
|
|
2014-09-18 15:48:07 +04:00
|
|
|
hopper("1").save(file)
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
im = Image.open(file)
|
|
|
|
im.load()
|
|
|
|
self.assertEqual(im.mode, "1")
|
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
|
|
self.assertEqual(im.format, "MSP")
|
|
|
|
|
2014-09-18 15:48:07 +04:00
|
|
|
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)
|
|
|
|
|
2014-11-01 10:55:15 +03:00
|
|
|
def test_cannot_save_wrong_mode(self):
|
2014-09-18 15:48:07 +04:00
|
|
|
# Arrange
|
|
|
|
im = hopper()
|
2014-11-01 10:55:15 +03:00
|
|
|
filename = self.tempfile("temp.msp")
|
2014-09-18 15:48:07 +04:00
|
|
|
|
|
|
|
# Act/Assert
|
2014-11-01 10:55:15 +03:00
|
|
|
self.assertRaises(IOError, lambda: im.save(filename))
|
2014-09-18 15:48:07 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
# End of file
|