show a meaningful skip message for image tests

This commit is contained in:
Daniel Graña 2013-06-20 10:49:14 -03:00
parent de57e27d81
commit 7a4c012db4
1 changed files with 5 additions and 3 deletions

View File

@ -6,13 +6,15 @@ from shutil import rmtree
from twisted.trial import unittest
skip = False
try:
from PIL import Image
except ImportError, e:
skip = True
skip = 'Missing Python Imaging Library, install https://pypi.python.org/pypi/Pillow'
else:
encoders = set(('jpeg_encoder', 'jpeg_decoder'))
skip = not encoders.issubset(set(Image.core.__dict__))
if not encoders.issubset(set(Image.core.__dict__)):
skip = 'Missing JPEG encoders'
def _mocked_download_func(request, info):
response = request.meta.get('response')
@ -49,7 +51,7 @@ class ImagesPipelineTestCase(unittest.TestCase):
def test_thumbnail_name(self):
thumbnail_name = self.pipeline.thumb_key
name = '50'
self.assertEqual(thumbnail_name("/tmp/foo.jpg", name),
self.assertEqual(thumbnail_name("/tmp/foo.jpg", name),
'thumbs/50/271f172bb4727281011c80fe763e93a47bb6b3fe.jpg')
self.assertEqual(thumbnail_name("foo.png", name),
'thumbs/50/0945c699b5580b99e4f40dffc009699b2b6830a7.jpg')