diff options
-rw-r--r-- | src/pyexiv2.py | 6 | ||||
-rw-r--r-- | unittest/iptc.py | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index 90ef36e..fd91bb4 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -572,7 +572,11 @@ class IptcTag(MetadataTag): else: raise IptcValueError(value, xtype) - # TODO: other types + elif xtype == 'Undefined': + if type(value) is str: + return value + else: + raise IptcValueError(value, xtype) raise IptcValueError(value, xtype) diff --git a/unittest/iptc.py b/unittest/iptc.py index 70eb977..9987b9d 100644 --- a/unittest/iptc.py +++ b/unittest/iptc.py @@ -151,3 +151,13 @@ class TestIptcTag(unittest.TestCase): 'Some binary data.') self.assertEqual(IptcTag._convert_to_python('�lj1�eEϟ�u����ᒻ;C(�SpI]���QI�}', xtype), '�lj1�eEϟ�u����ᒻ;C(�SpI]���QI�}') + + def test_convert_to_string_undefined(self): + xtype = 'Undefined' + # Valid values + self.assertEqual(IptcTag._convert_to_string('Some binary data.', xtype), + 'Some binary data.') + self.assertEqual(IptcTag._convert_to_string('�lj1�eEϟ�u����ᒻ;C(�SpI]���QI�}', xtype), + '�lj1�eEϟ�u����ᒻ;C(�SpI]���QI�}') + # Invalid values + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_string, None, xtype) |