diff options
Diffstat (limited to 'unittest/exif.py')
-rw-r--r-- | unittest/exif.py | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/unittest/exif.py b/unittest/exif.py index ae5fca0..d46f138 100644 --- a/unittest/exif.py +++ b/unittest/exif.py @@ -35,7 +35,6 @@ class TestExifTag(unittest.TestCase): # Valid values self.assertEqual(ExifTag._convert_to_python('23', xtype), 23) self.assertEqual(ExifTag._convert_to_python('+5628', xtype), 5628) - self.assertEqual(ExifTag._convert_to_python('-4', xtype), -4) # Invalid values self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype) self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype) @@ -46,8 +45,50 @@ class TestExifTag(unittest.TestCase): xtype = 'Short' # Valid values self.assertEqual(ExifTag._convert_to_string(123, xtype), '123') - self.assertEqual(ExifTag._convert_to_string(-57, xtype), '-57') # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, -57, xtype) self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 'invalid', xtype) - self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, '3.14', xtype) - self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, '1E3', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 3.14, xtype) + + def test_convert_to_python_long(self): + xtype = 'Long' + # Valid values + self.assertEqual(ExifTag._convert_to_python('23', xtype), 23) + self.assertEqual(ExifTag._convert_to_python('+5628', xtype), 5628) + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '47.0001', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '1E3', xtype) + + def test_convert_to_string_long(self): + xtype = 'Long' + # Valid values + self.assertEqual(ExifTag._convert_to_string(123, xtype), '123') + self.assertEqual(ExifTag._convert_to_string(678024, xtype), '678024') + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, -57, xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 'invalid', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 3.14, xtype) + + def test_convert_to_python_slong(self): + xtype = 'SLong' + # Valid values + self.assertEqual(ExifTag._convert_to_python('23', xtype), 23) + self.assertEqual(ExifTag._convert_to_python('+5628', xtype), 5628) + self.assertEqual(ExifTag._convert_to_python('-437', xtype), -437) + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '47.0001', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '1E3', xtype) + + def test_convert_to_string_slong(self): + xtype = 'SLong' + # Valid values + self.assertEqual(ExifTag._convert_to_string(123, xtype), '123') + self.assertEqual(ExifTag._convert_to_string(678024, xtype), '678024') + self.assertEqual(ExifTag._convert_to_string(-437, xtype), '-437') + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 'invalid', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 3.14, xtype) |