mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from PIL import Image
|
|
|
|
from .test_file_libtiff import LibTiffTestCase
|
|
|
|
|
|
class TestFileLibTiffSmall(LibTiffTestCase):
|
|
|
|
""" 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.
|
|
|
|
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. """
|
|
|
|
def test_g4_hopper_file(self):
|
|
"""Testing the open file load path"""
|
|
|
|
test_file = "Tests/images/hopper_g4.tif"
|
|
with open(test_file, 'rb') as f:
|
|
im = Image.open(f)
|
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
self._assert_noerr(im)
|
|
|
|
def test_g4_hopper_bytesio(self):
|
|
"""Testing the bytesio loading code path"""
|
|
from io import BytesIO
|
|
test_file = "Tests/images/hopper_g4.tif"
|
|
s = BytesIO()
|
|
with open(test_file, 'rb') as f:
|
|
s.write(f.read())
|
|
s.seek(0)
|
|
im = Image.open(s)
|
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
self._assert_noerr(im)
|
|
|
|
def test_g4_hopper(self):
|
|
"""The 128x128 lena image failed for some reason."""
|
|
|
|
test_file = "Tests/images/hopper_g4.tif"
|
|
im = Image.open(test_file)
|
|
|
|
self.assertEqual(im.size, (128, 128))
|
|
self._assert_noerr(im)
|