diff options
author | Guido van Rossum <guido@python.org> | 2001-09-18 20:04:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-09-18 20:04:26 (GMT) |
commit | 843daa8cad823ffafb217bc7c4b5e3c5ef9ff6c3 (patch) | |
tree | aed288f384fb854896885653affb4267a54a5957 /Lib/test/test_descr.py | |
parent | ceccae5365276f3b8858deb3f49815ff8e8f0b8c (diff) | |
download | cpython-843daa8cad823ffafb217bc7c4b5e3c5ef9ff6c3.zip cpython-843daa8cad823ffafb217bc7c4b5e3c5ef9ff6c3.tar.gz cpython-843daa8cad823ffafb217bc7c4b5e3c5ef9ff6c3.tar.bz2 |
Test for the safety check in wrap_cmpfunc().
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index dbfce0c..fc00318 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1304,6 +1304,21 @@ def specials(): for i in range(10): 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(): if verbose: print "Testing weak references..." |