diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-03-27 11:09:29 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-03-27 11:09:29 +0000 |
commit | 71b7fac07ba978630844bdabee59492e329d036c (patch) | |
tree | aadf120def2251712083dbb70c803f53498447ff /Lib/test/test_fractions.py | |
parent | 355adc5a451ce3b22b66a3af883d35e89e2a0eab (diff) | |
download | cpython-git-71b7fac07ba978630844bdabee59492e329d036c.tar.gz |
Make Fraction to complex comparisons with <=, <, >= or > raise TypeError.
Diffstat (limited to 'Lib/test/test_fractions.py')
-rw-r--r-- | Lib/test/test_fractions.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py index 63ac7fd57c..a24fcd3c3a 100644 --- a/Lib/test/test_fractions.py +++ b/Lib/test/test_fractions.py @@ -473,8 +473,21 @@ class FractionTest(unittest.TestCase): def testBigComplexComparisons(self): self.assertFalse(F(10**23) == complex(10**23)) - self.assertTrue(F(10**23) > complex(10**23)) - self.assertFalse(F(10**23) <= complex(10**23)) + self.assertRaises(TypeError, operator.gt, F(10**23), complex(10**23)) + self.assertRaises(TypeError, operator.le, F(10**23), complex(10**23)) + + x = F(3, 8) + z = complex(0.375, 0.0) + w = complex(0.375, 0.2) + self.assertTrue(x == z) + self.assertFalse(x != z) + self.assertFalse(x == w) + self.assertTrue(x != w) + for op in operator.lt, operator.le, operator.gt, operator.ge: + self.assertRaises(TypeError, op, x, z) + self.assertRaises(TypeError, op, z, x) + self.assertRaises(TypeError, op, x, w) + self.assertRaises(TypeError, op, w, x) def testMixedEqual(self): self.assertTrue(0.5 == F(1, 2)) |