diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Bug146313_TestCase.py | 73 | ||||
-rw-r--r-- | test/Bug173387_TestCase.py | 73 | ||||
-rw-r--r-- | test/Bug175070_TestCase.py | 77 | ||||
-rw-r--r-- | test/Bug183332_TestCase.py | 102 | ||||
-rw-r--r-- | test/Bug183618_TestCase.py | 85 | ||||
-rw-r--r-- | test/ReadMetadataTestCase.py | 103 | ||||
-rwxr-xr-x | test/TestsRunner.py | 61 | ||||
-rw-r--r-- | test/exif.py | 2 | ||||
-rw-r--r-- | test/iptc.py | 2 | ||||
-rw-r--r-- | test/metadata.py | 2 | ||||
-rw-r--r-- | test/notifying_list.py | 2 | ||||
-rw-r--r-- | test/rational.py | 2 | ||||
-rw-r--r-- | test/testutils.py | 42 | ||||
-rw-r--r-- | test/xmp.py | 2 |
14 files changed, 622 insertions, 6 deletions
diff --git a/test/Bug146313_TestCase.py b/test/Bug146313_TestCase.py new file mode 100644 index 0000000..06f9fa3 --- /dev/null +++ b/test/Bug146313_TestCase.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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: Bug146313_TestCase.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +import os.path +import pyexiv2 + +class Bug146313_TestCase(unittest.TestCase): + + """ + Test case for bug #146313. + + Summary: Passing the filename to the Image constructor as unicode fails. + Description: passing a unicode string to the constructor of pyexiv2.Image + throws an exception of type Boost.Python.ArgumentError. + Fix: fixed with revision 76. + """ + + def testNormalStringAscii(self): + """ + Test passing the constructor a normal string with ascii characters only. + """ + filename = os.path.join('data', 'smiley1.jpg') + image = pyexiv2.Image(filename) + + def testNormalStringExotic(self): + """ + Test passing the constructor a normal string with unicode characters. + """ + filename = os.path.join('data', 'bug146313_šmiléŷ.jpg') + image = pyexiv2.Image(filename) + + def testUnicodeStringAscii(self): + """ + Test passing the constructor a unicode string with ascii characters + only. + """ + filename = unicode(os.path.join('data', 'smiley1.jpg'), 'utf-8') + image = pyexiv2.Image(filename) + + def testUnicodeStringExotic(self): + """ + Test passing the constructor a unicode string with unicode characters. + """ + filename = unicode(os.path.join('data', 'bug146313_šmiléŷ.jpg'), 'utf-8') + image = pyexiv2.Image(filename) + diff --git a/test/Bug173387_TestCase.py b/test/Bug173387_TestCase.py new file mode 100644 index 0000000..5e9b845 --- /dev/null +++ b/test/Bug173387_TestCase.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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) + diff --git a/test/Bug175070_TestCase.py b/test/Bug175070_TestCase.py new file mode 100644 index 0000000..c1f6639 --- /dev/null +++ b/test/Bug175070_TestCase.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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/test/Bug183332_TestCase.py b/test/Bug183332_TestCase.py new file mode 100644 index 0000000..52025ec --- /dev/null +++ b/test/Bug183332_TestCase.py @@ -0,0 +1,102 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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: Bug183332_TestCase.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +import testutils +import os.path +import pyexiv2 + +class Bug183332_TestCase(unittest.TestCase): + + """ + Test case for bug #183332. + + Summary: Cached metadata is not converted to its correct type. + Description: When setting the value of a tag, its value is automatically + converted to the correct type, but the value held in the internal cache is + not. + """ + + def testSetEXIFTagValue(self): + """ + Test the value type of the internally cached metadata after setting an + EXIF tag. + """ + # 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.Artist' + self.assert_(key in image.exifKeys()) + value = 12 + # EXIF artist is a string, voluntarily pass an integer as argument + image[key] = value + self.assertEqual(image[key], str(value)) + + def testSetIPTCTagValue(self): + """ + Test the value type of the internally cached metadata after setting an + IPTC tag. + """ + # 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()) + values = (5, 6) + # IPTC keywords are strings, voluntarily pass integers as arguments + image[key] = values + self.assertEqual(image[key], tuple([str(v) for v in values])) + + def testSetNotSetEXIFTagValue(self): + """ + Test the value type of the internally cached metadata after setting an + EXIF tag that was not previously set. + """ + # 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.Model' + self.assert_(key not in image.exifKeys()) + value = 34L + # EXIF model is a string, voluntarily pass a long as argument + image[key] = value + self.assertEqual(image[key], str(value)) + diff --git a/test/Bug183618_TestCase.py b/test/Bug183618_TestCase.py new file mode 100644 index 0000000..bef3da3 --- /dev/null +++ b/test/Bug183618_TestCase.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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: Bug183618_TestCase.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +import testutils +import os.path +import pyexiv2 + +class Bug183618_TestCase(unittest.TestCase): + + """ + Test case for bug #183618. + + Summary: Exif.GPSInfo.{GPSLongitude,Latitude} are not decoded. + Description: The GPS latitude and longitude data is not correctly decoded + because multiple value fields for EXIF tags are not correctly dealt with: + only the first value is extracted and returned. + Fix: fixed with revision 79, behaviour changed with revision 82. + """ + + def checkTypeAndValue(self, tag, etype, evalue): + """ + Check the type and the value of a metadata tag against expected values. + + Keyword arguments: + tag -- the full name of the tag (eg. 'Exif.Image.DateTime') + etype -- the expected type of the tag value + evalue -- the expected value of the tag + """ + self.assertEqual(tag.__class__, etype) + self.assertEqual(tag, evalue) + + def testReadGPSMetadata(self): + """ + Test the extraction of the GPS metadata from a file. + """ + # Check that the reference file is not corrupted + filename = os.path.join('data', 'bug183618.jpg') + md5sum = 'ccddff432b0a2dc8f544f0f380e1fa6d' + self.assert_(testutils.CheckFileSum(filename, md5sum)) + + # Read the image metadata + image = pyexiv2.Image(filename) + image.readMetadata() + + # Exhaustive tests on the values of EXIF GPS metadata + gpsTags = [('Exif.Image.GPSTag', long, 1313L), + ('Exif.GPSInfo.GPSVersionID', str, '2 0 0 0 '), + ('Exif.GPSInfo.GPSLatitudeRef', str, 'N'), + ('Exif.GPSInfo.GPSLatitude', tuple, (pyexiv2.Rational(47, 1), pyexiv2.Rational(3817443, 1000000), pyexiv2.Rational(0, 1))), + ('Exif.GPSInfo.GPSLongitudeRef', str, 'E'), + ('Exif.GPSInfo.GPSLongitude', tuple, (pyexiv2.Rational(8, 1), pyexiv2.Rational(41359940, 1000000), pyexiv2.Rational(0, 1))), + ('Exif.GPSInfo.GPSAltitudeRef', str, '0 '), + ('Exif.GPSInfo.GPSAltitude', pyexiv2.Rational, pyexiv2.Rational(1908629, 1250)), + ('Exif.GPSInfo.GPSMapDatum', str, 'WGS-84')] + self.assertEqual([tag for tag in image.exifKeys() if tag.find('GPS') != -1], [tag[0] for tag in gpsTags]) + for tag in gpsTags: + self.checkTypeAndValue(image[tag[0]], tag[1], tag[2]) + diff --git a/test/ReadMetadataTestCase.py b/test/ReadMetadataTestCase.py new file mode 100644 index 0000000..b239bab --- /dev/null +++ b/test/ReadMetadataTestCase.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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: ReadMetadataTestCase.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +import testutils +import os.path +import pyexiv2 +import datetime + +class ReadMetadataTestCase(unittest.TestCase): + + """ + Test case on reading the metadata contained in a file. + """ + + def checkTypeAndValue(self, tag, etype, evalue): + """ + Check the type and the value of a metadata tag against expected values. + + Keyword arguments: + tag -- the full name of the tag (eg. 'Exif.Image.DateTime') + etype -- the expected type of the tag value + evalue -- the expected value of the tag + """ + self.assertEqual(tag.__class__, etype) + self.assertEqual(tag, evalue) + + def testReadMetadata(self): + """ + Perform various tests on reading the metadata contained in a file. + """ + # Check that the reference file is not corrupted + filename = os.path.join('data', 'smiley1.jpg') + md5sum = 'c066958457c685853293058f9bf129c1' + self.assert_(testutils.CheckFileSum(filename, md5sum)) + + # Read the image metadata + image = pyexiv2.Image(filename) + image.readMetadata() + + # Exhaustive tests on the values of EXIF metadata + exifTags = [('Exif.Image.ImageDescription', str, 'Well it is a smiley that happens to be green'), + ('Exif.Image.XResolution', pyexiv2.Rational, pyexiv2.Rational(72, 1)), + ('Exif.Image.YResolution', pyexiv2.Rational, pyexiv2.Rational(72, 1)), + ('Exif.Image.ResolutionUnit', int, 2), + ('Exif.Image.Software', str, 'ImageReady'), + ('Exif.Image.DateTime', datetime.datetime, datetime.datetime(2004, 7, 13, 21, 23, 44)), + ('Exif.Image.Artist', str, 'No one'), + ('Exif.Image.Copyright', str, ''), + ('Exif.Image.ExifTag', long, 226L), + ('Exif.Photo.Flash', int, 80), + ('Exif.Photo.PixelXDimension', long, 167L), + ('Exif.Photo.PixelYDimension', long, 140L)] + self.assertEqual(image.exifKeys(), [tag[0] for tag in exifTags]) + for tag in exifTags: + self.checkTypeAndValue(image[tag[0]], tag[1], tag[2]) + + # Exhaustive tests on the values of IPTC metadata + iptcTags = [('Iptc.Application2.Caption', str, 'yelimS green faced dude (iptc caption)'), + ('Iptc.Application2.Writer', str, 'Nobody'), + ('Iptc.Application2.Byline', str, 'Its me'), + ('Iptc.Application2.ObjectName', str, 'GreeenDude'), + ('Iptc.Application2.DateCreated', datetime.date, datetime.date(2004, 7, 13)), + ('Iptc.Application2.City', str, 'Seattle'), + ('Iptc.Application2.ProvinceState', str, 'WA'), + ('Iptc.Application2.CountryName', str, 'USA'), + ('Iptc.Application2.Category', str, 'Things'), + ('Iptc.Application2.Keywords', tuple, ('Green', 'Smiley', 'Dude')), + ('Iptc.Application2.Copyright', str, '\xa9 2004 Nobody')] + self.assertEqual(image.iptcKeys(), [tag[0] for tag in iptcTags]) + for tag in iptcTags: + self.checkTypeAndValue(image[tag[0]], tag[1], tag[2]) + + # Test on the JPEG comment + self.checkTypeAndValue(image.getComment(), + str, 'This is a jpeg comment, about the green smiley.') + diff --git a/test/TestsRunner.py b/test/TestsRunner.py new file mode 100755 index 0000000..2610f68 --- /dev/null +++ b/test/TestsRunner.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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. +# +# Author: Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest + +# Test cases to run +#from ReadMetadataTestCase import ReadMetadataTestCase +#from Bug146313_TestCase import Bug146313_TestCase +#from Bug173387_TestCase import Bug173387_TestCase +#from Bug175070_TestCase import Bug175070_TestCase +#from Bug183332_TestCase import Bug183332_TestCase +#from Bug183618_TestCase import Bug183618_TestCase +from rational import TestRational +from notifying_list import TestNotifyingList +from exif import TestExifTag +from iptc import TestIptcTag +from xmp import TestXmpTag +from metadata import TestImageMetadata + + +if __name__ == '__main__': + # Instantiate a test suite containing all the test cases + suite = unittest.TestSuite() + #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)) + #suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug183332_TestCase)) + #suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug183618_TestCase)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestRational)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestNotifyingList)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestExifTag)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestIptcTag)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestXmpTag)) + suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestImageMetadata)) + # Run the test suite + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/test/exif.py b/test/exif.py index 9837106..7db7386 100644 --- a/test/exif.py +++ b/test/exif.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2009 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # diff --git a/test/iptc.py b/test/iptc.py index dcbdd17..f5c63ba 100644 --- a/test/iptc.py +++ b/test/iptc.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2009 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # diff --git a/test/metadata.py b/test/metadata.py index 0d3a188..5a74c17 100644 --- a/test/metadata.py +++ b/test/metadata.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2009 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # diff --git a/test/notifying_list.py b/test/notifying_list.py index e80ec9c..7b63570 100644 --- a/test/notifying_list.py +++ b/test/notifying_list.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2009 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # diff --git a/test/rational.py b/test/rational.py index 070bf6c..1ee5670 100644 --- a/test/rational.py +++ b/test/rational.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2008-2009 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2008-2010 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # diff --git a/test/testutils.py b/test/testutils.py new file mode 100644 index 0000000..97ff611 --- /dev/null +++ b/test/testutils.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2010 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: testutils.py +# Author(s): Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import hashlib + +def CheckFileSum(filename, md5sum): + """ + Test the MD5 sum of a given file against the expected value. + + Keyword arguments: + filename -- the name of the file to test + md5sum -- the expected value of the MD5 sum of the file + """ + f = open(filename) + return (hashlib.md5(f.read()).hexdigest() == md5sum) + diff --git a/test/xmp.py b/test/xmp.py index cd0fabe..bbd9085 100644 --- a/test/xmp.py +++ b/test/xmp.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2009 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # |