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/xmp.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/xmp.py')
-rw-r--r-- | test/xmp.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/test/xmp.py b/test/xmp.py index 3379851..f3fa4c3 100644 --- a/test/xmp.py +++ b/test/xmp.py @@ -28,7 +28,7 @@ import unittest from pyexiv2.xmp import XmpTag, XmpValueError, register_namespace, \ unregister_namespace, unregister_namespaces -from pyexiv2.utils import FixedOffset, Rational, Fraction +from pyexiv2.utils import FixedOffset, make_fraction from pyexiv2.metadata import ImageMetadata import datetime @@ -288,8 +288,8 @@ class TestXmpTag(unittest.TestCase): # Valid values tag = XmpTag('Xmp.xmpDM.videoPixelAspectRatio') self.assertEqual(tag.type, 'Rational') - self.assertEqual(tag._convert_to_python('5/3', 'Rational'), Rational(5, 3)) - self.assertEqual(tag._convert_to_python('-5/3', 'Rational'), Rational(-5, 3)) + self.assertEqual(tag._convert_to_python('5/3', 'Rational'), make_fraction(5, 3)) + self.assertEqual(tag._convert_to_python('-5/3', 'Rational'), make_fraction(-5, 3)) # Invalid values self.failUnlessRaises(XmpValueError, tag._convert_to_python, 'invalid', 'Rational') @@ -300,11 +300,8 @@ class TestXmpTag(unittest.TestCase): # Valid values tag = XmpTag('Xmp.xmpDM.videoPixelAspectRatio') self.assertEqual(tag.type, 'Rational') - self.assertEqual(tag._convert_to_string(Rational(5, 3), 'Rational'), '5/3') - self.assertEqual(tag._convert_to_string(Rational(-5, 3), 'Rational'), '-5/3') - if Fraction is not None: - self.assertEqual(tag._convert_to_string(Fraction('1.6'), 'Rational'), '8/5') - self.assertEqual(tag._convert_to_string(Fraction('-1.6'), 'Rational'), '-8/5') + self.assertEqual(tag._convert_to_string(make_fraction(5, 3), 'Rational'), '5/3') + self.assertEqual(tag._convert_to_string(make_fraction(-5, 3), 'Rational'), '-5/3') # Invalid values self.failUnlessRaises(XmpValueError, tag._convert_to_string, 'invalid', 'Rational') |