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 /test/exif.py | |
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).
Diffstat (limited to 'test/exif.py')
-rw-r--r-- | test/exif.py | 25 |
1 files changed, 24 insertions, 1 deletions
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]) + |