Pillow/Tests/test_file_xpm.py

37 lines
796 B
Python
Raw Normal View History

2014-09-23 17:01:58 +04:00
from helper import unittest, PillowTestCase, hopper
from PIL import Image
# sample ppm stream
2014-09-23 17:01:58 +04:00
TEST_FILE = "Tests/images/hopper.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")
2015-04-24 02:26:52 +03:00
# large error due to quantization->44 colors.
2014-09-23 17:01:58 +04:00
self.assert_image_similar(im.convert('RGB'), hopper('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