diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2008-01-31 23:05:29 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2008-01-31 23:05:29 +0100 |
commit | c7cf21bd6a5e264be4b41933ceadb0e99470afcd (patch) | |
tree | b932f80f8db3d7ae453cadc6d96247942430ef76 /unittest/Bug173387_TestCase.py | |
parent | a57c825601e8f145b35c205072a2dc1ffa07d55c (diff) | |
download | pyexiv2-c7cf21bd6a5e264be4b41933ceadb0e99470afcd.tar.gz |
Added a unit test for bug #173387.
Diffstat (limited to 'unittest/Bug173387_TestCase.py')
-rw-r--r-- | unittest/Bug173387_TestCase.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/unittest/Bug173387_TestCase.py b/unittest/Bug173387_TestCase.py new file mode 100644 index 0000000..3caf8c9 --- /dev/null +++ b/unittest/Bug173387_TestCase.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2006-2007 Olivier Tilloy <olivier@tilloy.net> +# +# This file is part of the pyexiv2 distribution. +# +# pyexiv2 is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# pyexiv2 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyexiv2; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. +# +# +# File: Bug173387_TestCase.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +import testutils +import os.path +import pyexiv2 + +class Bug173387_TestCase(unittest.TestCase): + + """ + Test case for bug #173387. + + Summary: Error reading Exif.Photo.UserComment. + Description: Trying to read the value of EXIF tag 'Exif.Photo.UserComment' + fails if the comment is not encoded as an ASCII string. + Fix: fixed with revision 77. + """ + + def testEmptyUserComment(self): + """ + Test reading a so-called "empty" user comment (full of \x00 characters). + """ + # Check that the reference file is not corrupted + filename = os.path.join('data', 'bug173387_empty_usercomment.jpg') + md5sum = '75e5f18aece0955b518cefe1ffd30b7c' + self.assert_(testutils.CheckFileSum(filename, md5sum)) + + image = pyexiv2.Image(filename) + image.readMetadata() + self.assertEqual(image['Exif.Photo.UserComment'], '\x00' * 256) + + def testCorruptedUserComment(self): + """ + Test reading a corrupted user comment (full of non printable + characters). + """ + # Check that the reference file is not corrupted + filename = os.path.join('data', 'bug173387_corrupted_usercomment.jpg') + md5sum = '8007ac7357213fd2787bc817a6d7cd1d' + self.assert_(testutils.CheckFileSum(filename, md5sum)) + + image = pyexiv2.Image(filename) + image.readMetadata() + evalue = 'charset="InvalidCharsetId" \xff\xff\xaa\x00X\x00@\x00a\x00@\xff\xbb\x00x\x14F9\x05\x00\x08\xff\xcc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xdd\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00<\x00\x00\x00\x00\x00\x00\x00X\x02\x00\x00s\x00\x00\x00\x00\x00\x00\x00@\xb2#\x8c\x00\x00\x00\x01J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8c\x1e\x00\x00p:\xac\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<R\x14\x8cx$\x03\x8cDR\x14\x8c\xa8+\x14\x8c\x00\x00\x00\x00x.\x14\x8c\x00\x00\x00\x00\x00\x00\x00\x00\x98s\x01\x00\x10\x00\x00\x00\x18\x08\x15\x8c `\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x03\xe7\x00\x08\x00\x00\x02\x00@\x00\x00\t\x05\x00\x00\x19\x03\x00\x00\x03\x06\x10\x01\x80\x84\x1a\x8c\x08O\x1a\x8c\xf0L\x1a\x8c\x00\x00\x00\x00\x00\x00\x00\x00\x80D\x1a\x8c\x01\x00\x00\x00\xf0\x94\x15\xac' + self.assertEqual(image['Exif.Photo.UserComment'], evalue) + |