aboutsummaryrefslogtreecommitdiffstats
path: root/test/exif.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-11-30 20:47:00 +0100
committerOlivier Tilloy <olivier@tilloy.net>2010-11-30 20:47:00 +0100
commitbd8fdd0665f848a566ccfee0b8dff9c67a52488b (patch)
tree331b7e18b445c09d3c04b6c6e651613a4790ee19 /test/exif.py
parentaed5a5ebc8fa63834c2a29e1614debf4e92c04ac (diff)
downloadpyexiv2-bd8fdd0665f848a566ccfee0b8dff9c67a52488b.tar.gz
Conditional unit test for Fraction objects in EXIF tags.
Diffstat (limited to 'test/exif.py')
-rw-r--r--test/exif.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/exif.py b/test/exif.py
index 4ddb360..263437e 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
+from pyexiv2.utils import Rational, Fraction
import datetime
@@ -263,6 +263,8 @@ class TestExifTag(unittest.TestCase):
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')
# Invalid values
self.failUnlessRaises(ExifValueError, tag._convert_to_string, 'invalid')
@@ -287,6 +289,9 @@ class TestExifTag(unittest.TestCase):
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')
# Invalid values
self.failUnlessRaises(ExifValueError, tag._convert_to_string, 'invalid')