diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-03-02 09:57:28 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-03-02 09:57:28 +0100 |
commit | 6c1dd24fc1fe68390f76df69b8542c0652fd5d79 (patch) | |
tree | 975346689828ad0ffc706f5d51a2312b759e2bce /unittest | |
parent | 55fbb1a4cb21200c4f8b080bcfa755c6799db196 (diff) | |
download | pyexiv2-6c1dd24fc1fe68390f76df69b8542c0652fd5d79.tar.gz |
EXIF Undefined conversion.
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/exif.py | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/unittest/exif.py b/unittest/exif.py index 72fb089..86eab63 100644 --- a/unittest/exif.py +++ b/unittest/exif.py @@ -34,20 +34,20 @@ class TestExifTag(unittest.TestCase): def test_convert_to_python_ascii(self): xtype = 'Ascii' # Valid values: datetimes - self.assertEqual(ExifTag._convert_to_python('2009-03-01 12:46:51', xtype), + self.assertEqual(ExifTag._convert_to_python('2009-03-01 12:46:51', xtype, None), datetime.datetime(2009, 03, 01, 12, 46, 51)) - self.assertEqual(ExifTag._convert_to_python('2009:03:01 12:46:51', xtype), + self.assertEqual(ExifTag._convert_to_python('2009:03:01 12:46:51', xtype, None), datetime.datetime(2009, 03, 01, 12, 46, 51)) - self.assertEqual(ExifTag._convert_to_python('2009-03-01T12:46:51Z', xtype), + self.assertEqual(ExifTag._convert_to_python('2009-03-01T12:46:51Z', xtype, None), datetime.datetime(2009, 03, 01, 12, 46, 51)) # Valid values: strings - self.assertEqual(ExifTag._convert_to_python('Some text.', xtype), u'Some text.') - self.assertEqual(ExifTag._convert_to_python('Some text with exotic chàräctérʐ.', xtype), + self.assertEqual(ExifTag._convert_to_python('Some text.', xtype, None), u'Some text.') + self.assertEqual(ExifTag._convert_to_python('Some text with exotic chàräctérʐ.', xtype, None), u'Some text with exotic chàräctérʐ.') # Invalid values: datetimes - self.assertEqual(ExifTag._convert_to_python('2009-13-01 12:46:51', xtype), + self.assertEqual(ExifTag._convert_to_python('2009-13-01 12:46:51', xtype, None), u'2009-13-01 12:46:51') - self.assertEqual(ExifTag._convert_to_python('2009-12-01', xtype), + self.assertEqual(ExifTag._convert_to_python('2009-12-01', xtype, None), u'2009-12-01') def test_convert_to_string_ascii(self): @@ -69,13 +69,13 @@ class TestExifTag(unittest.TestCase): def test_convert_to_python_short(self): xtype = 'Short' # 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('23', xtype, None), 23) + self.assertEqual(ExifTag._convert_to_python('+5628', xtype, None), 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) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '47.0001', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '1E3', xtype, None) def test_convert_to_string_short(self): xtype = 'Short' @@ -89,13 +89,13 @@ class TestExifTag(unittest.TestCase): 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) + self.assertEqual(ExifTag._convert_to_python('23', xtype, None), 23) + self.assertEqual(ExifTag._convert_to_python('+5628', xtype, None), 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) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '47.0001', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '1E3', xtype, None) def test_convert_to_string_long(self): xtype = 'Long' @@ -110,14 +110,14 @@ class TestExifTag(unittest.TestCase): 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) + self.assertEqual(ExifTag._convert_to_python('23', xtype, None), 23) + self.assertEqual(ExifTag._convert_to_python('+5628', xtype, None), 5628) + self.assertEqual(ExifTag._convert_to_python('-437', xtype, None), -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) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '47.0001', xtype, None) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '1E3', xtype, None) def test_convert_to_string_slong(self): xtype = 'SLong' @@ -128,3 +128,13 @@ class TestExifTag(unittest.TestCase): # Invalid values self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 'invalid', xtype) self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 3.14, xtype) + + def test_convert_to_python_undefined(self): + xtype = 'Undefined' + # Valid values + self.assertEqual(ExifTag._convert_to_python('48 49 48 48 ', xtype, '1.00'), + u'1.00') + self.assertEqual(ExifTag._convert_to_python('3 ', xtype, 'Digital still camera'), + u'Digital still camera') + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype, None) |