Author: Antonio Cuni <[email protected]>
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)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit