diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2008-01-31 23:26:32 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2008-01-31 23:26:32 +0100 |
commit | f466a882835271cc98d59f4e77b105282bcaa76e (patch) | |
tree | cb2bac5a23ae080e549985f45abeb1f4df011100 /unittest | |
parent | c7cf21bd6a5e264be4b41933ceadb0e99470afcd (diff) | |
download | pyexiv2-f466a882835271cc98d59f4e77b105282bcaa76e.tar.gz |
Added a unit test for bug #175070.
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/Bug175070_TestCase.py | 77 | ||||
-rwxr-xr-x | unittest/TestsRunner.py | 2 |
2 files changed, 79 insertions, 0 deletions
diff --git a/unittest/Bug175070_TestCase.py b/unittest/Bug175070_TestCase.py new file mode 100644 index 0000000..2188b93 --- /dev/null +++ b/unittest/Bug175070_TestCase.py @@ -0,0 +1,77 @@ +#!/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: Bug175070_TestCase.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +import testutils +import os.path +import pyexiv2 + +class Bug175070_TestCase(unittest.TestCase): + + """ + Test case for bug #175070. + + Summary: Deleting a tag not previously accessed raises a KeyError exception. + Description: When trying to delete a tag present in an image but not + previously accessed, a KeyError exception is raised. + Fix: fixed with revision 78. + """ + + def testDeleteExifTag(self): + """ + Test deleting an EXIF tag not previously accessed. + """ + # Check that the reference file is not corrupted + filename = os.path.join('data', 'smiley1.jpg') + md5sum = 'c066958457c685853293058f9bf129c1' + self.assert_(testutils.CheckFileSum(filename, md5sum)) + + image = pyexiv2.Image(filename) + image.readMetadata() + key = 'Exif.Image.ImageDescription' + self.assert_(key in image.exifKeys()) + del image[key] + + def testDeleteIptcTag(self): + """ + Test deleting an IPTC tag not previously accessed. The IPTC tag is a + multiple values field, and the deletion is performed by assigning its + value an empty list. + """ + # Check that the reference file is not corrupted + filename = os.path.join('data', 'smiley1.jpg') + md5sum = 'c066958457c685853293058f9bf129c1' + self.assert_(testutils.CheckFileSum(filename, md5sum)) + + image = pyexiv2.Image(filename) + image.readMetadata() + key = 'Iptc.Application2.Keywords' + self.assert_(key in image.iptcKeys()) + image[key] = [] + diff --git a/unittest/TestsRunner.py b/unittest/TestsRunner.py index 248f8e3..122b82d 100755 --- a/unittest/TestsRunner.py +++ b/unittest/TestsRunner.py @@ -34,6 +34,7 @@ from RationalTestCase import RationalTestCase from ReadMetadataTestCase import ReadMetadataTestCase from Bug146313_TestCase import Bug146313_TestCase from Bug173387_TestCase import Bug173387_TestCase +from Bug175070_TestCase import Bug175070_TestCase if __name__ == '__main__': # Instantiate a test suite containing all the test cases @@ -42,6 +43,7 @@ if __name__ == '__main__': suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ReadMetadataTestCase)) suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug146313_TestCase)) suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug173387_TestCase)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug175070_TestCase)) # Run the test suite unittest.TextTestRunner(verbosity=2).run(suite) |