2014-09-23 17:01:58 +04:00
|
|
|
from helper import unittest, PillowTestCase, hopper
|
2012-10-25 17:12:13 +04:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
# sample ppm stream
|
2014-09-23 17:01:58 +04:00
|
|
|
TEST_FILE = "Tests/images/hopper.xpm"
|
2012-10-25 17:12:13 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
class TestFileXpm(PillowTestCase):
|
|
|
|
|
|
|
|
def test_sanity(self):
|
2014-07-18 00:23:50 +04:00
|
|
|
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-18 21:40:08 +04:00
|
|
|
|
2014-07-17 03:38:57 +04:00
|
|
|
def test_load_read(self):
|
|
|
|
# Arrange
|
2014-07-18 00:23:50 +04:00
|
|
|
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
|