mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
py3k: Add TarIO test
Not too convinced of the size fix. While it works against my file, I'm not sure someone would have accidentally been an index off and not noticed.
This commit is contained in:
parent
49b0d1563e
commit
d6a0dec15b
BIN
Images/lena.tar
Normal file
BIN
Images/lena.tar
Normal file
Binary file not shown.
|
@ -39,13 +39,13 @@ class TarIO(ContainerIO.ContainerIO):
|
|||
raise IOError("unexpected end of tar file")
|
||||
|
||||
name = s[:100].decode('utf-8')
|
||||
i = name.find(b'\0')
|
||||
i = name.find('\0')
|
||||
if i == 0:
|
||||
raise IOError("cannot find subfile")
|
||||
if i > 0:
|
||||
name = name[:i]
|
||||
|
||||
size = int(s[124:136], 8)
|
||||
size = int(s[124:135], 8)
|
||||
|
||||
if file == name:
|
||||
break
|
||||
|
|
22
Tests/test_file_tar.py
Normal file
22
Tests/test_file_tar.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from tester import *
|
||||
|
||||
from PIL import Image, TarIO
|
||||
|
||||
# sample ppm stream
|
||||
tarfile = "Images/lena.tar"
|
||||
|
||||
def test_sanity():
|
||||
tar = TarIO.TarIO(tarfile, 'lena.png')
|
||||
im = Image.open(tar)
|
||||
im.load()
|
||||
assert_equal(im.mode, "RGB")
|
||||
assert_equal(im.size, (128, 128))
|
||||
assert_equal(im.format, "PNG")
|
||||
|
||||
tar = TarIO.TarIO(tarfile, 'lena.jpg')
|
||||
im = Image.open(tar)
|
||||
im.load()
|
||||
assert_equal(im.mode, "RGB")
|
||||
assert_equal(im.size, (128, 128))
|
||||
assert_equal(im.format, "JPEG")
|
||||
|
Loading…
Reference in New Issue
Block a user