summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-03-13 09:48:39 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-03-13 09:48:39 (GMT)
commitf673f0c40c663c96539950ecd11333715e621c57 (patch)
tree1564f29bff4d8850062ec6de00f37b6ec1124123 /Lib
parentad0ef571b70bac3764792aaeb1d966b553ecd256 (diff)
downloadcpython-f673f0c40c663c96539950ecd11333715e621c57.zip
cpython-f673f0c40c663c96539950ecd11333715e621c57.tar.gz
cpython-f673f0c40c663c96539950ecd11333715e621c57.tar.bz2
Issue #7845: Make 1j.__le__(2j) return NotImplemented rather than raising TypeError.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_complex.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index 702227c..a857354 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -3,6 +3,7 @@ from test import support
from random import random
from math import atan2, isnan, copysign
+import operator
INF = float("inf")
NAN = float("nan")
@@ -110,15 +111,23 @@ class ComplexTest(unittest.TestCase):
def test_richcompare(self):
self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1<<10000)
- self.assertEqual(complex.__lt__(1+1j, None), NotImplemented)
+ self.assertIs(complex.__lt__(1+1j, None), NotImplemented)
self.assertIs(complex.__eq__(1+1j, 1+1j), True)
self.assertIs(complex.__eq__(1+1j, 2+2j), False)
self.assertIs(complex.__ne__(1+1j, 1+1j), False)
self.assertIs(complex.__ne__(1+1j, 2+2j), True)
- self.assertRaises(TypeError, complex.__lt__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__le__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__gt__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__ge__, 1+1j, 2+2j)
+ self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented)
+ self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.le, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.ge, 1+1j, 2+2j)
+ self.assertIs(operator.eq(1+1j, 1+1j), True)
+ self.assertIs(operator.eq(1+1j, 2+2j), False)
+ self.assertIs(operator.ne(1+1j, 1+1j), False)
+ self.assertIs(operator.ne(1+1j, 2+2j), True)
def test_mod(self):
# % is no longer supported on complex numbers