@@ -135,22 +135,25 @@ def test_info_from_jpg_marked_as_jp2(self):
135135 ident = '01%2f03%2f0001.jpg'
136136 uri = '%s/%s' % (self .URI_BASE , ident )
137137 formats = [ "jpg" , "png" , "gif" , "webp" ]
138- exception = loris_exception .ImageInfoException
139- function = img_info .ImageInfo .from_image_file
140- args = [uri , fp , fmt , formats ]
141- self .assertRaisesRegexp (exception , '^Invalid JP2 file$' , function , * args )
138+ #see http://stackoverflow.com/a/8673096
139+ try :
140+ img_info .ImageInfo .from_image_file (uri , fp , fmt , formats )
141+ self .fail ('should have thrown an ImageInfoException' )
142+ except loris_exception .ImageInfoException as iie :
143+ self .assertEqual (iie .message , 'Invalid JP2 file' )
142144
143145 def test_info_from_invalid_src_format (self ):
144146 fp = path .join (self .test_img_dir , '01' , '03' , '0001.jpg' )
145147 fmt = 'invalid_format'
146148 ident = '01%2f03%2f0001.jpg'
147149 uri = '%s/%s' % (self .URI_BASE , ident )
148150 formats = [ "jpg" , "png" , "gif" , "webp" ]
149- exception = loris_exception .ImageInfoException
150- error_message = 'Didn\' t get a source format, or at least one we recognize \("invalid_format"\)'
151- function = img_info .ImageInfo .from_image_file
152- args = [uri , fp , fmt , formats ]
153- self .assertRaisesRegexp (exception , error_message , function , * args )
151+ error_message = 'Didn\' t get a source format, or at least one we recognize ("invalid_format")'
152+ try :
153+ img_info .ImageInfo .from_image_file (uri , fp , fmt , formats )
154+ self .fail ('should have thrown an ImageInfoException' )
155+ except loris_exception .ImageInfoException as iie :
156+ self .assertEqual (iie .message , error_message )
154157
155158 def test_jpeg_info_from_image (self ):
156159 fp = self .test_jpeg_fp
0 commit comments