[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.59,1.60
Guido van Rossum
gvanrossum@users.sourceforge.net
Tue, 18 Sep 2001 13:04:28 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv17755
Modified Files:
test_descr.py
Log Message:
Test for the safety check in wrap_cmpfunc().
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** test_descr.py 2001/09/17 02:38:46 1.59
--- test_descr.py 2001/09/18 20:04:26 1.60
***************
*** 1305,1308 ****
--- 1305,1323 ----
verify(i in p10)
verify(10 not in p10)
+ # Safety test for __cmp__
+ def unsafecmp(a, b):
+ try:
+ a.__class__.__cmp__(a, b)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't allow %s.__cmp__(%r, %r)" % (
+ a.__class__, a, b)
+ unsafecmp(u"123", "123")
+ unsafecmp("123", u"123")
+ unsafecmp(1, 1.0)
+ unsafecmp(1.0, 1)
+ unsafecmp(1, 1L)
+ unsafecmp(1L, 1)
def weakrefs():