diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-03-06 09:47:28 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-03-06 09:47:28 +0100 |
commit | f2a4f351d61aca1dd24d62a3ec9893f0f3965fc0 (patch) | |
tree | b6a890d83b5473f990c9304b234b42d368acc79b /unittest/rational.py | |
parent | 6c1dd24fc1fe68390f76df69b8542c0652fd5d79 (diff) | |
download | pyexiv2-f2a4f351d61aca1dd24d62a3ec9893f0f3965fc0.tar.gz |
Reworked the Rational class.
Diffstat (limited to 'unittest/rational.py')
-rw-r--r-- | unittest/rational.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/unittest/rational.py b/unittest/rational.py new file mode 100644 index 0000000..8ae6d65 --- /dev/null +++ b/unittest/rational.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2008-2009 Olivier Tilloy <olivier@tilloy.net> +# +# This file is part of the pyexiv2 distribution. +# +# pyexiv2 is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# pyexiv2 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyexiv2; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. +# +# Author: Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +from pyexiv2 import Rational + + +class TestRational(unittest.TestCase): + + def test_constructor(self): + r = Rational(2, 1) + self.assertEqual(r.numerator, 2) + self.assertEqual(r.denominator, 1) + self.assertRaises(ZeroDivisionError, Rational, 1, 0) + + def test_equality(self): + r1 = Rational(2, 1) + r2 = Rational(2, 1) + r3 = Rational(8, 4) + r4 = Rational(3, 2) + self.assertEqual(r1, r2) + self.assertEqual(r1, r3) + self.assertNotEqual(r1, r4) |