aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-12-26 19:51:16 +0100
committerOlivier Tilloy <olivier@tilloy.net>2010-12-26 19:51:16 +0100
commit3ece0524d87364f9edb40b70b95d8c39937572b9 (patch)
tree1b20734e849b77da34fdef024efb214b4576f73e /test/utils.py
parent66afe34c75790fba2b8395ce781bd9d16868e0e3 (diff)
downloadpyexiv2-3ece0524d87364f9edb40b70b95d8c39937572b9.tar.gz
New convenience function to factorize further the code that handles fractions: fraction_to_string(...).
Diffstat (limited to 'test/utils.py')
-rw-r--r--test/utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/utils.py b/test/utils.py
index ceddcc3..11b1766 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -27,7 +27,8 @@
import unittest
from pyexiv2.utils import undefined_to_string, string_to_undefined, \
- Rational, Fraction, is_fraction, make_fraction
+ Rational, Fraction, \
+ is_fraction, make_fraction, fraction_to_string
class TestConversions(unittest.TestCase):
@@ -88,3 +89,10 @@ class TestFractions(unittest.TestCase):
self.assertRaises(TypeError, make_fraction, 5, 3, 2)
self.assertRaises(TypeError, make_fraction, None)
+ def test_fraction_to_string(self):
+ self.assertEqual(fraction_to_string(make_fraction(3, 5)), '3/5')
+ self.assertEqual(fraction_to_string(make_fraction(-3, 5)), '-3/5')
+ self.assertEqual(fraction_to_string(make_fraction(0, 1)), '0/1')
+ self.assertRaises(TypeError, fraction_to_string, None)
+ self.assertRaises(TypeError, fraction_to_string, 'invalid')
+