Browse Source

Add test for SyntaxError thrown by IptcImagePlugin, assert log

pull/357/head
tudacs 7 years ago
parent
commit
0adffcbcb5
  1. 9
      tests/test_image.py

9
tests/test_image.py

@ -1,6 +1,7 @@
import os
import PIL
import pytest
from unittest.mock import Mock, patch
from PIL import Image
from sigal import init_logging
@ -160,7 +161,7 @@ def test_get_exif_tags():
assert 'gps' not in simple
def test_get_iptc_data():
def test_get_iptc_data(caplog):
test_image = '1.jpg'
src_file = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'iptcTest',
test_image)
@ -180,6 +181,12 @@ def test_get_iptc_data():
test_image)
assert get_iptc_data(src_file) == {}
# Test catching the SyntaxError -- assert output
config = {'getiptcinfo.side_effect':SyntaxError}
with patch('sigal.image.IptcImagePlugin.getiptcinfo', side_effect=SyntaxError) as i:
get_iptc_data(src_file)
assert ['IPTC Error in'] == [ log.message[:13] for log in caplog.records ]
def test_iso_speed_ratings():
data = {'ISOSpeedRatings': ()}

Loading…
Cancel
Save