[pypy-svn] pypy default: Fix this test when run with "-A" on top of CPython.
arigo
commits-noreply at bitbucket.org
Fri Apr 1 15:46:23 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r43082:92490211ef94
Date: 2011-04-01 15:45 +0200
http://bitbucket.org/pypy/pypy/changeset/92490211ef94/
Log: Fix this test when run with "-A" on top of CPython. Also fix it when
run on top of PyPy to check that when setdefault() inserts the value
in a *non-empty* dict, it is still done with only one call to
__hash__().
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -804,7 +804,6 @@
return w_default
def dict_setdefault__DictMulti_ANY_ANY(space, w_dict, w_key, w_default):
- # XXX should be more efficient, with only one dict lookup
return w_dict.setdefault(w_key, w_default)
def dict_pop__DictMulti_ANY(space, w_dict, w_key, defaults_w):
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -152,6 +152,8 @@
class AppTest_DictObject:
+ def setup_class(cls):
+ cls.w_on_pypy = cls.space.wrap("__pypy__" in sys.builtin_module_names)
def test_equality(self):
d = {1:2}
@@ -271,10 +273,17 @@
k = Key()
d = {}
d.setdefault(k, [])
- assert k.calls == 1
+ if self.on_pypy:
+ assert k.calls == 1
d.setdefault(k, 1)
- assert k.calls == 2
+ if self.on_pypy:
+ assert k.calls == 2
+
+ k = Key()
+ d.setdefault(k, 42)
+ if self.on_pypy:
+ assert k.calls == 1
def test_update(self):
d = {1:2, 3:4}
More information about the Pypy-commit
mailing list