2
# -*- coding: utf-8 -*-
4
# ******************************************************************************
6
# Copyright (C) 2008-2010 Olivier Tilloy <olivier@tilloy.net>
8
# This file is part of the pyexiv2 distribution.
10
# pyexiv2 is free software; you can redistribute it and/or
11
# modify it under the terms of the GNU General Public License
12
# as published by the Free Software Foundation; either version 2
13
# of the License, or (at your option) any later version.
15
# pyexiv2 is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
20
# You should have received a copy of the GNU General Public License
21
# along with pyexiv2; if not, write to the Free Software
22
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
25
# File: Bug175070_TestCase.py
26
# Author(s): Olivier Tilloy <olivier@tilloy.net>
28
# ******************************************************************************
35
class Bug175070_TestCase(unittest.TestCase):
38
Test case for bug #175070.
40
Summary: Deleting a tag not previously accessed raises a KeyError exception.
41
Description: When trying to delete a tag present in an image but not
42
previously accessed, a KeyError exception is raised.
43
Fix: fixed with revision 78.
46
def testDeleteExifTag(self):
48
Test deleting an EXIF tag not previously accessed.
50
# Check that the reference file is not corrupted
51
filename = os.path.join('data', 'smiley1.jpg')
52
md5sum = 'c066958457c685853293058f9bf129c1'
53
self.assert_(testutils.CheckFileSum(filename, md5sum))
55
image = pyexiv2.Image(filename)
57
key = 'Exif.Image.ImageDescription'
58
self.assert_(key in image.exifKeys())
61
def testDeleteIptcTag(self):
63
Test deleting an IPTC tag not previously accessed. The IPTC tag is a
64
multiple values field, and the deletion is performed by assigning its
67
# Check that the reference file is not corrupted
68
filename = os.path.join('data', 'smiley1.jpg')
69
md5sum = 'c066958457c685853293058f9bf129c1'
70
self.assert_(testutils.CheckFileSum(filename, md5sum))
72
image = pyexiv2.Image(filename)
74
key = 'Iptc.Application2.Keywords'
75
self.assert_(key in image.iptcKeys())