summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-24 17:52:04 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-24 17:52:04 (GMT)
commit2205642fe0af9c00bbfa713dae1c8ba4562d2236 (patch)
tree4dadb02c974dad9e00ebe1ec1b5a43e12fba18eb /Lib/test
parente47df7a2117c14eb5b0445a3002766d54e75278d (diff)
downloadcpython-2205642fe0af9c00bbfa713dae1c8ba4562d2236.zip
cpython-2205642fe0af9c00bbfa713dae1c8ba4562d2236.tar.gz
cpython-2205642fe0af9c00bbfa713dae1c8ba4562d2236.tar.bz2
Do the same thing to complex that I did to str: the rich comparison
function returns NotImplemented when comparing objects whose tp_richcompare slot is not itself.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index ed3cea4..42e1384 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1863,6 +1863,21 @@ def classic_comparisons():
def rich_comparisons():
if verbose:
print "Testing rich comparisons..."
+ class Z(complex):
+ pass
+ z = Z(1)
+ verify(z == 1+0j)
+ verify(1+0j == z)
+ class ZZ(complex):
+ def __eq__(self, other):
+ try:
+ return abs(self - other) <= 1e-6
+ except:
+ return NotImplemented
+ zz = ZZ(1.0000003)
+ verify(zz == 1+0j)
+ verify(1+0j == zz)
+
class classic:
pass
for base in (classic, int, object, list):