~osomon/pyexiv2/scons-check-python-version

« back to all changes in this revision

Viewing changes to test/Bug175070_TestCase.py

  • Committer: Olivier Tilloy
  • Date: 2010-03-18 22:55:22 UTC
  • mfrom: (286 pyexiv2-0.2)
  • mto: This revision was merged to the branch mainline in revision 288.
  • Revision ID: olivier@tilloy.net-20100318225522-m4armcwfo2svbrz9
Merge the master branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
# -*- coding: utf-8 -*-
3
 
 
4
 
# ******************************************************************************
5
 
#
6
 
# Copyright (C) 2008-2010 Olivier Tilloy <olivier@tilloy.net>
7
 
#
8
 
# This file is part of the pyexiv2 distribution.
9
 
#
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.
14
 
#
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.
19
 
#
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.
23
 
#
24
 
#
25
 
# File:      Bug175070_TestCase.py
26
 
# Author(s): Olivier Tilloy <olivier@tilloy.net>
27
 
#
28
 
# ******************************************************************************
29
 
 
30
 
import unittest
31
 
import testutils
32
 
import os.path
33
 
import pyexiv2
34
 
 
35
 
class Bug175070_TestCase(unittest.TestCase):
36
 
 
37
 
    """
38
 
    Test case for bug #175070.
39
 
 
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.
44
 
    """
45
 
 
46
 
    def testDeleteExifTag(self):
47
 
        """
48
 
        Test deleting an EXIF tag not previously accessed.
49
 
        """
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))
54
 
 
55
 
        image = pyexiv2.Image(filename)
56
 
        image.readMetadata()
57
 
        key = 'Exif.Image.ImageDescription'
58
 
        self.assert_(key in image.exifKeys())
59
 
        del image[key]
60
 
 
61
 
    def testDeleteIptcTag(self):
62
 
        """
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
65
 
        value an empty list.
66
 
        """
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))
71
 
 
72
 
        image = pyexiv2.Image(filename)
73
 
        image.readMetadata()
74
 
        key = 'Iptc.Application2.Keywords'
75
 
        self.assert_(key in image.iptcKeys())
76
 
        image[key] = []
77