2014-07-07 21:03:50 +04:00
|
|
|
from helper import unittest
|
2013-04-22 00:53:43 +04:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
2014-08-26 20:57:15 +04:00
|
|
|
from test_file_libtiff import LibTiffTestCase
|
2013-04-22 00:53:43 +04:00
|
|
|
|
|
|
|
|
2014-08-26 20:57:15 +04:00
|
|
|
class TestFileLibTiffSmall(LibTiffTestCase):
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
""" The small lena image was failing on open in the libtiff
|
|
|
|
decoder because the file pointer was set to the wrong place
|
|
|
|
by a spurious seek. It wasn't failing with the byteio method.
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
It was fixed by forcing an lseek to the beginning of the
|
|
|
|
file just before reading in libtiff. These tests remain
|
|
|
|
to ensure that it stays fixed. """
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-09-23 11:30:55 +04:00
|
|
|
def test_g4_hopper_file(self):
|
2014-06-10 13:10:47 +04:00
|
|
|
"""Testing the open file load path"""
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2015-04-24 11:24:52 +03:00
|
|
|
test_file = "Tests/images/hopper_g4.tif"
|
|
|
|
with open(test_file, 'rb') as f:
|
2014-06-10 13:10:47 +04:00
|
|
|
im = Image.open(f)
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
|
|
self._assert_noerr(im)
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-09-23 11:30:55 +04:00
|
|
|
def test_g4_hopper_bytesio(self):
|
2014-06-10 13:10:47 +04:00
|
|
|
"""Testing the bytesio loading code path"""
|
|
|
|
from io import BytesIO
|
2015-04-24 11:24:52 +03:00
|
|
|
test_file = "Tests/images/hopper_g4.tif"
|
2014-06-10 13:10:47 +04:00
|
|
|
s = BytesIO()
|
2015-04-24 11:24:52 +03:00
|
|
|
with open(test_file, 'rb') as f:
|
2014-06-10 13:10:47 +04:00
|
|
|
s.write(f.read())
|
|
|
|
s.seek(0)
|
|
|
|
im = Image.open(s)
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
|
|
self._assert_noerr(im)
|
2013-07-01 02:42:19 +04:00
|
|
|
|
2014-09-23 11:30:55 +04:00
|
|
|
def test_g4_hopper(self):
|
|
|
|
"""The 128x128 lena image failed for some reason."""
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2015-04-24 11:24:52 +03:00
|
|
|
test_file = "Tests/images/hopper_g4.tif"
|
|
|
|
im = Image.open(test_file)
|
2013-04-22 00:53:43 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
|
|
self._assert_noerr(im)
|
2013-07-01 02:42:19 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|