diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2010-12-14 21:00:32 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2010-12-14 21:00:32 +0100 |
commit | 6aafad0f05982768868ce14fde28fb88b9a41e81 (patch) | |
tree | 5e2993a0808f43deba8a515b969049ad7191c3f4 /test | |
parent | ffaaf470541fbc36153a4c7a897e83a806307f33 (diff) | |
download | pyexiv2-6aafad0f05982768868ce14fde28fb88b9a41e81.tar.gz |
Factorize the test data checksums in a dictionary.
Diffstat (limited to 'test')
-rw-r--r-- | test/usercomment.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/test/usercomment.py b/test/usercomment.py index 5827bcf..651224d 100644 --- a/test/usercomment.py +++ b/test/usercomment.py @@ -33,54 +33,60 @@ import os.path class TestUserComment(unittest.TestCase): - def _read_image(self, filename, checksum): + checksums = { + 'usercomment-ascii.jpg': 'ad29ac65fb6f63c8361aaed6cb02f8c7', + 'usercomment-unicode-ii.jpg': '13b7cc09129a8677f2cf18634f5abd3c', + 'usercomment-unicode-mm.jpg': '7addfed7823c556ba489cd4ab2037200', + } + + def _read_image(self, filename): filepath = testutils.get_absolute_file_path(os.path.join('data', filename)) - self.assert_(testutils.CheckFileSum(filepath, checksum)) + self.assert_(testutils.CheckFileSum(filepath, self.checksums[filename])) m = ImageMetadata(filepath) m.read() return m def test_read_ascii(self): - m = self._read_image('usercomment-ascii.jpg', 'ad29ac65fb6f63c8361aaed6cb02f8c7') + m = self._read_image('usercomment-ascii.jpg') tag = m['Exif.Photo.UserComment'] self.assertEqual(tag.raw_value, 'charset="Ascii" deja vu') self.assertEqual(tag.value, u'deja vu') def test_read_unicode_little_endian(self): - m = self._read_image('usercomment-unicode-ii.jpg', '13b7cc09129a8677f2cf18634f5abd3c') + m = self._read_image('usercomment-unicode-ii.jpg') tag = m['Exif.Photo.UserComment'] self.assertEqual(tag.raw_value, 'charset="Unicode" d\x00\xe9\x00j\x00\xe0\x00 \x00v\x00u\x00') self.assertEqual(tag.value, u'déjà vu') def test_read_unicode_big_endian(self): - m = self._read_image('usercomment-unicode-mm.jpg', '7addfed7823c556ba489cd4ab2037200') + m = self._read_image('usercomment-unicode-mm.jpg') tag = m['Exif.Photo.UserComment'] 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') + m = self._read_image('usercomment-ascii.jpg') 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') + m = self._read_image('usercomment-ascii.jpg') 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') + m = self._read_image('usercomment-unicode-ii.jpg') 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') + m = self._read_image('usercomment-unicode-mm.jpg') 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') |