mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
test_file_tar: skip if codecs are not available.
The .tar test requires both jpeg & zlib support. If one of the two is unavailable, run the test for the second one. If both are unavailable, skip the test.
This commit is contained in:
parent
d1c6db88d4
commit
6afa11ec02
|
@ -2,21 +2,27 @@ from tester import *
|
||||||
|
|
||||||
from PIL import Image, TarIO
|
from PIL import Image, TarIO
|
||||||
|
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
if "zip_decoder" not in codecs and "jpeg_decoder" not in codecs:
|
||||||
|
skip("neither jpeg nor zip support not available")
|
||||||
|
|
||||||
# sample ppm stream
|
# sample ppm stream
|
||||||
tarfile = "Images/lena.tar"
|
tarfile = "Images/lena.tar"
|
||||||
|
|
||||||
def test_sanity():
|
def test_sanity():
|
||||||
tar = TarIO.TarIO(tarfile, 'lena.png')
|
if "zip_decoder" in codecs:
|
||||||
im = Image.open(tar)
|
tar = TarIO.TarIO(tarfile, 'lena.png')
|
||||||
im.load()
|
im = Image.open(tar)
|
||||||
assert_equal(im.mode, "RGB")
|
im.load()
|
||||||
assert_equal(im.size, (128, 128))
|
assert_equal(im.mode, "RGB")
|
||||||
assert_equal(im.format, "PNG")
|
assert_equal(im.size, (128, 128))
|
||||||
|
assert_equal(im.format, "PNG")
|
||||||
|
|
||||||
tar = TarIO.TarIO(tarfile, 'lena.jpg')
|
if "jpeg_decoder" in codecs:
|
||||||
im = Image.open(tar)
|
tar = TarIO.TarIO(tarfile, 'lena.jpg')
|
||||||
im.load()
|
im = Image.open(tar)
|
||||||
assert_equal(im.mode, "RGB")
|
im.load()
|
||||||
assert_equal(im.size, (128, 128))
|
assert_equal(im.mode, "RGB")
|
||||||
assert_equal(im.format, "JPEG")
|
assert_equal(im.size, (128, 128))
|
||||||
|
assert_equal(im.format, "JPEG")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user