diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2010-12-26 19:30:33 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2010-12-26 19:30:33 +0100 |
commit | 66afe34c75790fba2b8395ce781bd9d16868e0e3 (patch) | |
tree | d2109d2a2bd0a627ce06f27e99f7b5d04558073b /test/exif.py | |
parent | f178386b9ec255d7456977bb23b205802a0452e7 (diff) | |
download | pyexiv2-66afe34c75790fba2b8395ce781bd9d16868e0e3.tar.gz |
Handle fractions in a transparent manner,
using the convenience functions defined in module pyexiv2.utils.
Diffstat (limited to 'test/exif.py')
-rw-r--r-- | test/exif.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/test/exif.py b/test/exif.py index 1f929b7..38e19b7 100644 --- a/test/exif.py +++ b/test/exif.py @@ -27,7 +27,7 @@ import unittest from pyexiv2.exif import ExifTag, ExifValueError -from pyexiv2.utils import Rational, Fraction +from pyexiv2.utils import make_fraction import datetime @@ -260,7 +260,7 @@ class TestExifTag(unittest.TestCase): # Valid values tag = ExifTag('Exif.Image.XResolution') self.assertEqual(tag.type, 'Rational') - self.assertEqual(tag._convert_to_python('5/3'), Rational(5, 3)) + self.assertEqual(tag._convert_to_python('5/3'), make_fraction(5, 3)) # Invalid values self.failUnlessRaises(ExifValueError, tag._convert_to_python, 'invalid') @@ -272,21 +272,19 @@ class TestExifTag(unittest.TestCase): # Valid values tag = ExifTag('Exif.Image.XResolution') self.assertEqual(tag.type, 'Rational') - self.assertEqual(tag._convert_to_string(Rational(5, 3)), '5/3') - if Fraction is not None: - self.assertEqual(tag._convert_to_string(Fraction('1.6')), '8/5') + self.assertEqual(tag._convert_to_string(make_fraction(5, 3)), '5/3') # Invalid values self.failUnlessRaises(ExifValueError, tag._convert_to_string, 'invalid') self.failUnlessRaises(ExifValueError, - tag._convert_to_string, Rational(-5, 3)) + tag._convert_to_string, make_fraction(-5, 3)) def test_convert_to_python_srational(self): # Valid values tag = ExifTag('Exif.Image.BaselineExposure') self.assertEqual(tag.type, 'SRational') - self.assertEqual(tag._convert_to_python('5/3'), Rational(5, 3)) - self.assertEqual(tag._convert_to_python('-5/3'), Rational(-5, 3)) + self.assertEqual(tag._convert_to_python('5/3'), make_fraction(5, 3)) + self.assertEqual(tag._convert_to_python('-5/3'), make_fraction(-5, 3)) # Invalid values self.failUnlessRaises(ExifValueError, tag._convert_to_python, 'invalid') @@ -297,11 +295,8 @@ class TestExifTag(unittest.TestCase): # Valid values tag = ExifTag('Exif.Image.BaselineExposure') self.assertEqual(tag.type, 'SRational') - self.assertEqual(tag._convert_to_string(Rational(5, 3)), '5/3') - self.assertEqual(tag._convert_to_string(Rational(-5, 3)), '-5/3') - if Fraction is not None: - self.assertEqual(tag._convert_to_string(Fraction('1.6')), '8/5') - self.assertEqual(tag._convert_to_string(Fraction('-1.6')), '-8/5') + self.assertEqual(tag._convert_to_string(make_fraction(5, 3)), '5/3') + self.assertEqual(tag._convert_to_string(make_fraction(-5, 3)), '-5/3') # Invalid values self.failUnlessRaises(ExifValueError, tag._convert_to_string, 'invalid') |