diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2011-08-20 11:43:09 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2011-08-20 11:43:09 +0200 |
commit | a5a74fecd321629f06e3517f075d3f2e18776e10 (patch) | |
tree | eb749d216e2c282688a58b43c6e14fbb3c57fb85 | |
parent | 1349de1bbed0dd8d6e92e62b24fc39ba3da0d92d (diff) | |
download | pyexiv2-a5a74fecd321629f06e3517f075d3f2e18776e10.tar.gz |
Added a unit test to verify that the type of an EXIF makernote tag is correctly set when extracted from an image.
Currently failing (see https://bugs.launchpad.net/pyexiv2/+bug/781464).
-rw-r--r-- | test/data/MD5SUMS | 1 | ||||
-rw-r--r-- | test/data/pentax-makernote.jpg | bin | 0 -> 47549 bytes | |||
-rw-r--r-- | test/exif.py | 25 |
3 files changed, 25 insertions, 1 deletions
diff --git a/test/data/MD5SUMS b/test/data/MD5SUMS index c664932..c692790 100644 --- a/test/data/MD5SUMS +++ b/test/data/MD5SUMS @@ -1,5 +1,6 @@ e8525211f62a0944db9072f73750258c empty.jpg 64d4b7eab1e78f1f6bfb3c966e99eef2 exiv2-bug540.jpg +646804b309a4a2d31feafe9bffc5d7f0 pentax-makernote.jpg c066958457c685853293058f9bf129c1 smiley1.jpg ad29ac65fb6f63c8361aaed6cb02f8c7 usercomment-ascii.jpg 13b7cc09129a8677f2cf18634f5abd3c usercomment-unicode-ii.jpg diff --git a/test/data/pentax-makernote.jpg b/test/data/pentax-makernote.jpg Binary files differnew file mode 100644 index 0000000..67638ab --- /dev/null +++ b/test/data/pentax-makernote.jpg diff --git a/test/exif.py b/test/exif.py index 918f100..7f45b4e 100644 --- a/test/exif.py +++ b/test/exif.py @@ -2,7 +2,7 @@ # ****************************************************************************** # -# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net> +# Copyright (C) 2009-2011 Olivier Tilloy <olivier@tilloy.net> # # This file is part of the pyexiv2 distribution. # @@ -27,6 +27,7 @@ import unittest from pyexiv2.exif import ExifTag, ExifValueError +from pyexiv2.metadata import ImageMetadata from pyexiv2.utils import make_fraction import datetime @@ -334,3 +335,25 @@ class TestExifTag(unittest.TestCase): value = '2 0 0 foo' self.failUnlessRaises(ValueError, tag._set_raw_value, value) + def test_makernote_types(self): + # Makernote tags not attached to an image have an Undefined type by + # default. When read from an existing image though, their type should be + # correctly set (see https://bugs.launchpad.net/pyexiv2/+bug/781464). + tag1 = ExifTag('Exif.Pentax.PreviewResolution') + tag1.raw_value = '640 480' + self.assertEqual(tag1.type, 'Undefined') + self.failUnlessRaises(ValueError, getattr, tag1, 'value') + tag2 = ExifTag('Exif.Pentax.CameraInfo') + tag2.raw_value = '76830 20070527 2 1 4228109' + self.assertEqual(tag2.type, 'Undefined') + self.failUnlessRaises(ValueError, getattr, tag2, 'value') + + metadata = ImageMetadata('test/data/pentax-makernote.jpg') + metadata.read() + tag1 = metadata[tag1.key] + self.assertEqual(tag1.type, 'Short') + self.assertEqual(tag1.value, [640, 480]) + tag2 = metadata[tag2.key] + self.assertEqual(tag2.type, 'Long') + self.assertEqual(tag2.value, [76830L, 20070527L, 2L, 1L, 4228109L]) + |