From 6afa11ec02df3d5e9e6b8da3c1eee91b7e6146aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 21 Apr 2013 10:04:58 +0200 Subject: [PATCH] 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. --- Tests/test_file_tar.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Tests/test_file_tar.py b/Tests/test_file_tar.py index 0f87ea2c0..fa33d3802 100644 --- a/Tests/test_file_tar.py +++ b/Tests/test_file_tar.py @@ -2,21 +2,27 @@ from tester import * 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 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") + if "zip_decoder" in codecs: + 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") + if "jpeg_decoder" in codecs: + 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")