Commits

Chris Beaven committed 4a8c7e3

Fix tests, punt to 3.2.2

Comments (0)

Files changed (4)

  
 setup(
     name = 'sorl-thumbnail',
-    version = '3.2.1',
+    version = '3.2.2',
     url = 'http://code.google.com/p/sorl-thumbnail/',
-    download_url = 'http://sorl-thumbnail.googlecode.com/files/sorl-thumbnail-3.2.1.tar.gz',
+    download_url = 'http://sorl-thumbnail.googlecode.com/files/sorl-thumbnail-3.2.2.tar.gz',
     description = 'Thumbnails for Django',
     packages = [
         'sorl',

sorl/thumbnail/base.py

         self.dest = dest
 
         # Thumbnail settings
-        self.requested_size = requested_size
+        try:
+            x, y = [int(v) for v in requested_size]
+        except (TypeError, ValueError):
+            raise TypeError('Thumbnail received invalid value for size '
+                            'argument: %s' % repr(requested_size))
+        else:
+            self.requested_size = (x, y)
         try:
             self.quality = int(quality) 
             if not 0 < quality <= 100:

sorl/thumbnail/tests/classes.py

 
         thumb = DjangoThumbnail(relative_source=RELATIVE_PIC_NAME,
                                 requested_size=(240, 120), opts=valid_options)
-        expected = os.path.join(settings.MEDIA_ROOT, basename)
-        expected += '_240x120_autocrop_bw_crop_detail_sharpen_upscale_q85.jpg'
+        expected = (os.path.join(settings.MEDIA_ROOT, basename) + '_240x120_'
+                    'autocrop_bw_crop_detail_max_sharpen_upscale_q85.jpg')
         self.verify_thumbnail((240, 120), thumb, expected_filename=expected)
 
         # Different basedir

sorl/thumbnail/tests/templatetags.py

 from PIL import Image
 from django.conf import settings
 from django.template import Template, Context, TemplateSyntaxError
+from sorl.thumbnail.base import ThumbnailException
 from sorl.thumbnail.tests.classes import BaseTest, RELATIVE_PIC_NAME
 
 
         self.assertEqual(self.render_template(src_missing), '')
         # ...and with THUMBNAIL_DEBUG = True
         self.change_settings.change({'DEBUG': True})
-        self.assertRaises(TemplateSyntaxError, self.render_template,
-                          src_invalid)
-        self.assertRaises(TemplateSyntaxError, self.render_template,
-                          src_missing)
+        self.assertRaises(TypeError, self.render_template, src_invalid)
+        self.assertRaises(TypeError, self.render_template, src_missing)
 
         # Invalid source
         src = '{% thumbnail invalid_source 80x80 %}'
         self.assertEqual(self.render_template(src), '')
         # ...and with THUMBNAIL_DEBUG = True
         self.change_settings.change({'DEBUG': True})
-        self.assertRaises(TemplateSyntaxError, self.render_template, src)
-        self.assertRaises(TemplateSyntaxError, self.render_template,
+        self.assertRaises(ThumbnailException, self.render_template, src)
+        self.assertRaises(ThumbnailException, self.render_template,
                           src_on_context)
 
         # Non-existant source
         self.assertEqual(self.render_template(src), '')
         # ...and with THUMBNAIL_DEBUG = True
         self.change_settings.change({'DEBUG': True})
-        self.assertRaises(TemplateSyntaxError, self.render_template, src)
+        self.assertRaises(ThumbnailException, self.render_template, src)
 
         # Invalid size as a tuple:
         src = '{% thumbnail source invalid_size %}'
         self.assertEqual(self.render_template(src), '')
         # ...and THUMBNAIL_DEBUG = True
         self.change_settings.change({'DEBUG': True})
-        self.assertRaises(TemplateSyntaxError, self.render_template, src)
+        self.assertRaises(TypeError, self.render_template, src)
         # Invalid size as a string:
         src = '{% thumbnail source invalid_strsize %}'
         # ...with THUMBNAIL_DEBUG = False