aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-08-07 10:09:24 +0200
committerOlivier Tilloy <olivier@tilloy.net>2009-08-07 10:09:24 +0200
commitd9cb2ac5e54b6126119c9f34f7268a1fc4deb3ad (patch)
tree592da754b0a541c4743be9e993fe0ffdd48cab5e /unittest
parentbedad87240fdc63dc37c1fd859642284eed63a74 (diff)
downloadpyexiv2-d9cb2ac5e54b6126119c9f34f7268a1fc4deb3ad.tar.gz
Rational's numerator and denominator are read-only properties.
This will avoid setting the attributes of a tag's Rational value where the metadata container wouldn't be notified of the changes.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/rational.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittest/rational.py b/unittest/rational.py
index b10811d..990d282 100644
--- a/unittest/rational.py
+++ b/unittest/rational.py
@@ -36,6 +36,21 @@ class TestRational(unittest.TestCase):
self.assertEqual(r.denominator, 1)
self.assertRaises(ZeroDivisionError, Rational, 1, 0)
+ def test_read_only(self):
+ r = Rational(3, 4)
+ try:
+ r.numerator = 5
+ except AttributeError:
+ pass
+ else:
+ self.fail('Numerator is not read-only.')
+ try:
+ r.denominator = 5
+ except AttributeError:
+ pass
+ else:
+ self.fail('Denominator is not read-only.')
+
def test_from_string(self):
self.assertEqual(Rational.from_string('4/3'), Rational(4, 3))
self.assertEqual(Rational.from_string('-4/3'), Rational(-4, 3))