[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.71,1.72
Guido van Rossum
gvanrossum@users.sourceforge.net
Mon, 24 Sep 2001 10:52:06 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv24951/Lib/test
Modified Files:
test_descr.py
Log Message:
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.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** test_descr.py 2001/09/24 16:51:54 1.71
--- test_descr.py 2001/09/24 17:52:04 1.72
***************
*** 1864,1867 ****
--- 1864,1882 ----
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