2014-09-05 14:03:56 +04:00
|
|
|
from helper import unittest, PillowTestCase, hopper, tostring
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
from PIL import ImageFileIO
|
|
|
|
|
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class TestImageFileIo(PillowTestCase):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_fileio(self):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class DumbFile:
|
|
|
|
def __init__(self, data):
|
|
|
|
self.data = data
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def read(self, bytes=None):
|
|
|
|
assert(bytes is None)
|
|
|
|
return self.data
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def close(self):
|
|
|
|
pass
|
2013-07-01 02:42:19 +04:00
|
|
|
|
2014-09-05 14:03:56 +04:00
|
|
|
im1 = hopper()
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
io = ImageFileIO.ImageFileIO(DumbFile(tostring(im1, "PPM")))
|
|
|
|
|
|
|
|
im2 = Image.open(io)
|
|
|
|
self.assert_image_equal(im1, im2)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
# End of file
|