[pypy-commit] pypy identity-dict-strategy: a passing test

antocuni noreply at buildbot.pypy.org
Thu Jul 21 13:48:48 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: identity-dict-strategy
Changeset: r45804:3fa4e79e2664
Date: 2011-07-21 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/3fa4e79e2664/

Log:	a passing test

diff --git a/pypy/objspace/std/test/test_identitydict.py b/pypy/objspace/std/test/test_identitydict.py
--- a/pypy/objspace/std/test/test_identitydict.py
+++ b/pypy/objspace/std/test/test_identitydict.py
@@ -167,3 +167,23 @@
         d = {x: 1}
         assert self.uses_identity_strategy(d)
         assert list(iter(d)) == [x]
+
+    def test_mutate_class_and_then_compare(self):
+        class X(object):
+            pass
+        class Y(object):
+            pass
+
+        x = X()
+        y = Y()
+        d1 = {x: 1}
+        d2 = {y: 1}
+        assert self.uses_identity_strategy(d1)
+        assert self.uses_identity_strategy(d2)
+        #
+        X.__hash__ = lambda self: hash(y)
+        X.__eq__ = lambda self, other: True
+        #
+        assert d1 == d2
+        assert self.uses_identity_strategy(d1)
+        assert not self.uses_identity_strategy(d2)


More information about the pypy-commit mailing list