From bf44e3a8746b21dec56f1f8c61c077e36e4c03cd Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Sun, 17 Jan 2010 12:08:19 +0100 Subject: 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. --- test/exif.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/exif.py') 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') -- cgit