2014-06-10 04:36:40 +04:00
|
|
|
from test.helper import unittest, PillowTestCase, lena, tostring
|
2014-06-06 16:19:28 +04:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
from PIL import ImageFileIO
|
|
|
|
|
|
|
|
|
|
|
|
class TestImageFileIo(PillowTestCase):
|
|
|
|
|
|
|
|
def test_fileio(self):
|
|
|
|
|
|
|
|
class DumbFile:
|
|
|
|
def __init__(self, data):
|
|
|
|
self.data = data
|
2014-06-06 16:26:48 +04:00
|
|
|
|
2014-06-06 16:19:28 +04:00
|
|
|
def read(self, bytes=None):
|
2014-06-06 16:26:48 +04:00
|
|
|
assert(bytes is None)
|
2014-06-06 16:19:28 +04:00
|
|
|
return self.data
|
2014-06-06 16:26:48 +04:00
|
|
|
|
2014-06-06 16:19:28 +04:00
|
|
|
def close(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
im1 = lena()
|
|
|
|
|
|
|
|
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
|