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:
Michał Górny 2013-04-21 10:04:58 +02:00
parent d1c6db88d4
commit 6afa11ec02

View File

@ -2,10 +2,15 @@ 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():
if "zip_decoder" in codecs:
tar = TarIO.TarIO(tarfile, 'lena.png') tar = TarIO.TarIO(tarfile, 'lena.png')
im = Image.open(tar) im = Image.open(tar)
im.load() im.load()
@ -13,6 +18,7 @@ def test_sanity():
assert_equal(im.size, (128, 128)) assert_equal(im.size, (128, 128))
assert_equal(im.format, "PNG") assert_equal(im.format, "PNG")
if "jpeg_decoder" in codecs:
tar = TarIO.TarIO(tarfile, 'lena.jpg') tar = TarIO.TarIO(tarfile, 'lena.jpg')
im = Image.open(tar) im = Image.open(tar)
im.load() im.load()