aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-12-14 20:56:49 +0100
committerOlivier Tilloy <olivier@tilloy.net>2010-12-14 20:56:49 +0100
commitffaaf470541fbc36153a4c7a897e83a806307f33 (patch)
tree34320b14bfb41fc7270bbe6f59e017b53052b3c4 /test
parentd3e24bf8f84836dad9eccca32fa0f40f9682e218 (diff)
downloadpyexiv2-ffaaf470541fbc36153a4c7a897e83a806307f33.tar.gz
Unit test writing comments.
Diffstat (limited to 'test')
-rw-r--r--test/usercomment.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/usercomment.py b/test/usercomment.py
index 82d1e9d..5827bcf 100644
--- a/test/usercomment.py
+++ b/test/usercomment.py
@@ -58,3 +58,31 @@ class TestUserComment(unittest.TestCase):
self.assertEqual(tag.raw_value, 'charset="Unicode" \x00d\x00\xe9\x00j\x00\xe0\x00 \x00v\x00u')
self.assertEqual(tag.value, u'déjà vu')
+ def test_write_ascii(self):
+ m = self._read_image('usercomment-ascii.jpg', 'ad29ac65fb6f63c8361aaed6cb02f8c7')
+ tag = m['Exif.Photo.UserComment']
+ tag.value = 'foo bar'
+ self.assertEqual(tag.raw_value, 'charset="Ascii" foo bar')
+ self.assertEqual(tag.value, u'foo bar')
+
+ def test_write_unicode_over_ascii(self):
+ m = self._read_image('usercomment-ascii.jpg', 'ad29ac65fb6f63c8361aaed6cb02f8c7')
+ tag = m['Exif.Photo.UserComment']
+ tag.value = u'déjà vu'
+ self.assertEqual(tag.raw_value, 'déjà vu')
+ self.assertEqual(tag.value, u'déjà vu')
+
+ def test_write_unicode_little_endian(self):
+ m = self._read_image('usercomment-unicode-ii.jpg', '13b7cc09129a8677f2cf18634f5abd3c')
+ tag = m['Exif.Photo.UserComment']
+ tag.value = u'DÉJÀ VU'
+ self.assertEqual(tag.raw_value, 'charset="Unicode" D\x00\xc9\x00J\x00\xc0\x00 \x00V\x00U\x00')
+ self.assertEqual(tag.value, u'DÉJÀ VU')
+
+ def test_write_unicode_big_endian(self):
+ m = self._read_image('usercomment-unicode-mm.jpg', '7addfed7823c556ba489cd4ab2037200')
+ tag = m['Exif.Photo.UserComment']
+ tag.value = u'DÉJÀ VU'
+ self.assertEqual(tag.raw_value, 'charset="Unicode" \x00D\x00\xc9\x00J\x00\xc0\x00 \x00V\x00U')
+ self.assertEqual(tag.value, u'DÉJÀ VU')
+