aboutsummaryrefslogtreecommitdiffstats
path: root/test/exif.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-12-26 19:30:33 +0100
committerOlivier Tilloy <olivier@tilloy.net>2010-12-26 19:30:33 +0100
commit66afe34c75790fba2b8395ce781bd9d16868e0e3 (patch)
treed2109d2a2bd0a627ce06f27e99f7b5d04558073b /test/exif.py
parentf178386b9ec255d7456977bb23b205802a0452e7 (diff)
downloadpyexiv2-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.py21
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')