]> granicus.if.org Git - python/commitdiff
Given a class without __cmp__ or __eq__, cmp() of two instances of
authorGuido van Rossum <guido@python.org>
Wed, 15 Aug 2001 21:02:20 +0000 (21:02 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 15 Aug 2001 21:02:20 +0000 (21:02 +0000)
that class should compare the id() of those instances.  Add a test
that verifies this.  This test currently fails; I believe this is
caused by object.c:2.132 (Patch #424475 by loewis).

Lib/test/test_compare.py

index 9184355f2f49d147325f26b87d1cf7f5ce6b2c4b..1d8b94767230025bba894a8fe15727715c3bfbe0 100644 (file)
@@ -44,5 +44,13 @@ def test():
                     print "%s == %s" % (a, b)
                 else:
                     print "%s != %s" % (a, b)
+    # Ensure default comparison compares id() of args
+    L = [None]
+    for i in range(10):
+        L.insert(len(L)/2, Empty())
+    for a in L:
+        for b in L:
+            if cmp(a, b) != cmp(id(a), id(b)):
+                print "ERROR:", cmp(a, b), cmp(id(a), id(b)), id(a), id(b)
 
 test()