aboutsummaryrefslogtreecommitdiffstats
path: root/test/xmp.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2011-08-17 18:56:52 +0200
committerOlivier Tilloy <olivier@tilloy.net>2011-08-17 18:56:52 +0200
commit8f076d1fe72e3ad167bbbd29b076b88d7143ef3a (patch)
tree6b00931a4d081bf8f23fd775c6082cc23dd43e5a /test/xmp.py
parentf58166679a8334bd9a75647a6bc4a0c227f7f254 (diff)
downloadpyexiv2-8f076d1fe72e3ad167bbbd29b076b88d7143ef3a.tar.gz
Check the type before setting a tag’s value and raise a TypeError if it doesn’t match.
Diffstat (limited to 'test/xmp.py')
-rw-r--r--test/xmp.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/xmp.py b/test/xmp.py
index 7e7522e..c0ea11f 100644
--- a/test/xmp.py
+++ b/test/xmp.py
@@ -2,7 +2,7 @@
# ******************************************************************************
#
-# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net>
+# Copyright (C) 2009-2011 Olivier Tilloy <olivier@tilloy.net>
#
# This file is part of the pyexiv2 distribution.
#
@@ -364,6 +364,16 @@ class TestXmpTag(unittest.TestCase):
self.failUnlessEqual(tag.type, 'Lang Alt')
self.failUnlessRaises(ValueError, tag._set_value, {})
+ def test_set_value_incorrect_type(self):
+ # Expecting a list of values
+ tag = XmpTag('Xmp.dc.publisher')
+ self.failUnlessRaises(TypeError, tag._set_value, None)
+ self.failUnlessRaises(TypeError, tag._set_value, 'bleh')
+ # Expecting a dictionary mapping language codes to values
+ tag = XmpTag('Xmp.dc.description')
+ self.failUnlessRaises(TypeError, tag._set_value, None)
+ self.failUnlessRaises(TypeError, tag._set_value, 'bleh')
+
class TestXmpNamespaces(unittest.TestCase):