diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2010-01-17 12:08:19 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2010-01-17 12:08:19 +0100 |
commit | bf44e3a8746b21dec56f1f8c61c077e36e4c03cd (patch) | |
tree | cbdf196e26dd9183fddd9a006281ffe5b21e53b9 /test/exif.py | |
parent | 39ef8d00c9e7f45791e1a76d63edec30b9ff4297 (diff) | |
download | pyexiv2-bf44e3a8746b21dec56f1f8c61c077e36e4c03cd.tar.gz |
Support the EXIF SShort type (handled similarly as Short).
This doesn't seem to be standard EXIF but it is mentioned in the TIFF specification.
Diffstat (limited to 'test/exif.py')
-rw-r--r-- | test/exif.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/exif.py b/test/exif.py index cd077cd..6cb4f77 100644 --- a/test/exif.py +++ b/test/exif.py @@ -162,6 +162,31 @@ class TestExifTag(unittest.TestCase): self.failUnlessRaises(ExifValueError, tag._convert_to_string, 'invalid') self.failUnlessRaises(ExifValueError, tag._convert_to_string, 3.14) + def test_convert_to_python_sshort(self): + # Valid values + tag = ExifTag('Exif.Image.TimeZoneOffset') + self.assertEqual(tag.type, 'SShort') + self.assertEqual(tag._convert_to_python('8'), 8) + self.assertEqual(tag._convert_to_python('+5'), 5) + self.assertEqual(tag._convert_to_python('-6'), -6) + + # Invalid values + self.failUnlessRaises(ExifValueError, tag._convert_to_python, 'abc') + self.failUnlessRaises(ExifValueError, tag._convert_to_python, '5,64') + self.failUnlessRaises(ExifValueError, tag._convert_to_python, '47.0001') + self.failUnlessRaises(ExifValueError, tag._convert_to_python, '1E3') + + def test_convert_to_string_sshort(self): + # Valid values + tag = ExifTag('Exif.Image.TimeZoneOffset') + self.assertEqual(tag.type, 'SShort') + self.assertEqual(tag._convert_to_string(12), '12') + self.assertEqual(tag._convert_to_string(-3), '-3') + + # Invalid values + self.failUnlessRaises(ExifValueError, tag._convert_to_string, 'invalid') + self.failUnlessRaises(ExifValueError, tag._convert_to_string, 3.14) + def test_convert_to_python_long(self): # Valid values tag = ExifTag('Exif.Image.ImageWidth') |