Pillow/Tests/test_file_libtiff_small.py

57 lines
1.5 KiB
Python
Raw Normal View History

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-06-10 13:10:47 +04:00
from test_file_libtiff import TestFileLibTiff
2013-04-22 00:53:43 +04:00
2014-06-10 13:10:47 +04:00
class TestFileLibTiffSmall(TestFileLibTiff):
2014-06-10 13:10:47 +04:00
# Inherits TestFileLibTiff's setUp() and self._assert_noerr()
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-06-10 13:10:47 +04:00
def test_g4_lena_file(self):
"""Testing the open file load path"""
2013-04-22 00:53:43 +04:00
2014-06-10 13:10:47 +04:00
file = "Tests/images/lena_g4.tif"
with open(file, 'rb') as f:
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-06-10 13:10:47 +04:00
def test_g4_lena_bytesio(self):
"""Testing the bytesio loading code path"""
from io import BytesIO
file = "Tests/images/lena_g4.tif"
s = BytesIO()
with open(file, 'rb') as f:
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)
2014-06-10 13:10:47 +04:00
def test_g4_lena(self):
"""The 128x128 lena image fails for some reason. Investigating"""
2013-04-22 00:53:43 +04:00
2014-06-10 13:10:47 +04:00
file = "Tests/images/lena_g4.tif"
im = Image.open(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)
2014-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()
# End of file