Skip to content

Commit b2c6583

Browse files
bcailjpstroop
authored andcommitted
add python 2.6 to Travis (#266)
* add python 2.6 to Travis * update some assert statements to be compatible with python2.6 * test Exception messages in a different way, since assertRaisesRegexp was added in 2.7
1 parent a0623b4 commit b2c6583

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ addons:
1717
language: python
1818

1919
python:
20+
- "2.6"
2021
- "2.7"
2122

2223
# before_install:

tests/abstract_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def test_format(self):
2121
def test_resolve(self):
2222
expected_resolved = (self.expected_filepath, self.expected_format)
2323
resolved = self.resolver.resolve(self.identifier)
24-
self.assertSequenceEqual(resolved, expected_resolved)
24+
self.assertEqual(resolved[0], expected_resolved[0])
25+
self.assertEqual(resolved[1], expected_resolved[1])
2526

2627
def test_resolve_exception(self):
27-
with self.assertRaises(loris_exception.ResolverException):
28-
self.resolver.resolve(self.not_identifier)
28+
self.assertRaises(loris_exception.ResolverException, lambda: self.resolver.resolve(self.not_identifier))

tests/img_info_t.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tests/resolver_t.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ def test_simple_http_resolver(self):
237237

238238
ident = '0002'
239239
resolved_path, fmt = self.app.resolver.resolve(ident)
240-
self.assertIsNotNone(resolved_path)
240+
self.assertTrue(resolved_path)
241241
self.assertEqual(fmt, 'tif')
242242
self.assertTrue(isfile(resolved_path))
243243

244244
ident = '0003'
245245
resolved_path, fmt = self.app.resolver.resolve(ident)
246-
self.assertIsNotNone(resolved_path)
246+
self.assertTrue(resolved_path)
247247
self.assertEqual(fmt, 'tif')
248248
self.assertTrue(isfile(resolved_path))
249249

tests/simple_http_resolver_ut.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def test_does_not_exist(self):
102102
def test_resolve_001(self):
103103
expected_resolved = (self.expected_filepath, self.expected_format)
104104
resolved = self.resolver.resolve(self.identifier)
105-
self.assertSequenceEqual(resolved, expected_resolved)
105+
self.assertEqual(resolved[0], expected_resolved[0])
106+
self.assertEqual(resolved[1], expected_resolved[1])
106107
# Make sure the file exists in the cache
107108
self.assertTrue(os.path.isfile(self.expected_filepath))
108109

0 commit comments

Comments
 (0)