Skip to content

Commit 078b32d

Browse files
Test functions enabled by EXV_ENABLE_FILESYSTEM
Previously the functions were ignored if EXV_ENABLE_FILESYSTEM is off, now we check they throw the correct exception.
1 parent 1818f90 commit 078b32d

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

tests/test_exif.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,27 @@ def test_ExifThumb(self):
231231
thumb.setJpegThumbnail(
232232
data, exiv2.URational((160, 1)), exiv2.URational((120, 1)), 1)
233233
self.assertEqual(len(thumb.copy()), 2532)
234-
if not exiv2.versionInfo()['EXV_ENABLE_FILESYSTEM']:
235-
self.skipTest('EXV_ENABLE_FILESYSTEM is off')
236234
with tempfile.TemporaryDirectory() as tmp_dir:
237235
temp_file = os.path.join(tmp_dir, 'thumb')
238-
self.assertEqual(thumb.writeFile(temp_file), 2532)
236+
if exiv2.versionInfo()['EXV_ENABLE_FILESYSTEM']:
237+
self.assertEqual(thumb.writeFile(temp_file), 2532)
238+
else:
239+
with self.assertRaises(exiv2.Exiv2Error):
240+
thumb.writeFile(temp_file)
239241
temp_file += thumb.extension()
240242
thumb.erase()
241243
self.assertEqual(len(thumb.copy()), 0)
242-
thumb.setJpegThumbnail(temp_file)
243-
self.assertEqual(len(thumb.copy()), 2532)
244-
thumb.erase()
245-
self.assertEqual(len(thumb.copy()), 0)
246-
thumb.setJpegThumbnail(temp_file, exiv2.URational((160, 1)),
247-
exiv2.URational((120, 1)), 1)
248-
self.assertEqual(len(thumb.copy()), 2532)
244+
if exiv2.versionInfo()['EXV_ENABLE_FILESYSTEM']:
245+
thumb.setJpegThumbnail(temp_file)
246+
self.assertEqual(len(thumb.copy()), 2532)
247+
thumb.erase()
248+
self.assertEqual(len(thumb.copy()), 0)
249+
thumb.setJpegThumbnail(temp_file, exiv2.URational((160, 1)),
250+
exiv2.URational((120, 1)), 1)
251+
self.assertEqual(len(thumb.copy()), 2532)
252+
else:
253+
with self.assertRaises(exiv2.Exiv2Error):
254+
thumb.setJpegThumbnail(temp_file)
249255

250256
def test_ref_counts(self):
251257
self.image.readMetadata()

tests/test_preview.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ def test_PreviewImage(self):
6565
self.check_result(preview.mimeType(), str, 'image/jpeg')
6666
self.check_result(preview.size(), int, 2532)
6767
self.check_result(preview.width(), int, 160)
68-
if not exiv2.versionInfo()['EXV_ENABLE_FILESYSTEM']:
69-
self.skipTest('EXV_ENABLE_FILESYSTEM is off')
7068
with tempfile.TemporaryDirectory() as tmp_dir:
7169
temp_file = os.path.join(tmp_dir, 'image.jpg')
72-
self.assertEqual(preview.writeFile(temp_file), 2532)
70+
if exiv2.versionInfo()['EXV_ENABLE_FILESYSTEM']:
71+
self.assertEqual(preview.writeFile(temp_file), 2532)
72+
else:
73+
with self.assertRaises(exiv2.Exiv2Error):
74+
preview.writeFile(temp_file)
7375

7476
def test_PreviewManager(self):
7577
manager = exiv2.PreviewManager(self.image)

0 commit comments

Comments
 (0)