Pillow/Tests/test_file_libtiff_small.py

48 lines
1.4 KiB
Python
Raw Normal View History

from io import BytesIO
2013-04-22 00:53:43 +04:00
from PIL import Image
from .test_file_libtiff import LibTiffTestCase
2013-04-22 00:53:43 +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"
2019-06-13 18:54:11 +03:00
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"""
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()
2019-06-13 18:54:11 +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)
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)