[pypy-commit] pypy dict-strategies: test and fix
cfbolz
noreply at buildbot.pypy.org
Fri May 27 11:27:46 CEST 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: dict-strategies
Changeset: r44538:4a6f53750fdd
Date: 2011-05-27 11:19 +0200
http://bitbucket.org/pypy/pypy/changeset/4a6f53750fdd/
Log: test and fix
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
@@ -198,7 +198,7 @@
def setitem_str(self, w_dict, key, w_value):
self.switch_to_string_strategy(w_dict)
- self.setitem_str(w_dict, key, w_value)
+ w_dict.setitem_str(key, w_value)
def delitem(self, w_dict, w_key):
# in case the key is unhashable, try to hash it
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
@@ -747,6 +747,28 @@
assert "s" not in d
assert F() not in d
+class AppTestStrategies(object):
+ def w_get_strategy(self, obj):
+ import __pypy__
+ r = __pypy__.internal_repr(obj)
+ return r[r.find("(") + 1: r.find(")")]
+
+ def test_empty_to_string(self):
+ d = {}
+ assert "EmptyDictStrategy" in self.get_strategy(d)
+ d["a"] = 1
+ assert "StringDictStrategy" in self.get_strategy(d)
+
+ class O(object):
+ pass
+ o = O()
+ d = o.__dict__ = {}
+ assert "EmptyDictStrategy" in self.get_strategy(d)
+ o.a = 1
+ assert "StringDictStrategy" in self.get_strategy(d)
+
+
+
class FakeString(str):
hash_count = 0
More information about the pypy-commit
mailing list