Pillow/Tests/test_file_xpm.py

37 lines
790 B
Python
Raw Normal View History

from helper import unittest, PillowTestCase, lena
from PIL import Image
# sample ppm stream
TEST_FILE = "Tests/images/lena.xpm"
2014-06-10 13:10:47 +04:00
class TestFileXpm(PillowTestCase):
def test_sanity(self):
im = Image.open(TEST_FILE)
2014-06-10 13:10:47 +04:00
im.load()
self.assertEqual(im.mode, "P")
self.assertEqual(im.size, (128, 128))
self.assertEqual(im.format, "XPM")
#large error due to quantization->44 colors.
self.assert_image_similar(im.convert('RGB'), lena('RGB'), 60)
2014-07-17 03:38:57 +04:00
def test_load_read(self):
# Arrange
im = Image.open(TEST_FILE)
2014-07-17 03:38:57 +04:00
dummy_bytes = 1
# Act
data = im.load_read(dummy_bytes)
# Assert
self.assertEqual(len(data), 16384)
2014-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()
# End of file