-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
test_file_libtiff_small.py
47 lines (33 loc) · 1.4 KB
/
test_file_libtiff_small.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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)