diff options
-rw-r--r-- | src/pyexiv2/iptc.py | 2 | ||||
-rw-r--r-- | test/iptc.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/pyexiv2/iptc.py b/src/pyexiv2/iptc.py index 4ba6b21..46d543f 100644 --- a/src/pyexiv2/iptc.py +++ b/src/pyexiv2/iptc.py @@ -81,6 +81,8 @@ class IptcTag(MetadataTag, ListenerInterface): return self._values def _set_values(self, new_values): + if not isinstance(new_values, (list, tuple)): + raise TypeError('Expecting a list of values') if self.metadata is not None: raw_values = map(self._convert_to_string, new_values) self.metadata._set_iptc_tag_values(self.key, raw_values) diff --git a/test/iptc.py b/test/iptc.py index 5473090..4a8e4fe 100644 --- a/test/iptc.py +++ b/test/iptc.py @@ -213,6 +213,12 @@ class TestIptcTag(unittest.TestCase): # Invalid values self.failUnlessRaises(IptcValueError, tag._convert_to_string, None) + def test_set_single_value_raises(self): + tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \ + 'city of object data origin according to guidelines ' \ + 'established by the provider.', 'String', ['Seattle']) + self.failUnlessRaises(TypeError, tag._set_values, 'Barcelona') + def test_set_values_no_metadata(self): tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \ 'city of object data origin according to guidelines ' \ |