Author: Carl Friedrich Bolz <[email protected]>
Branch: virtual-arguments
Changeset: r54404:a9db929b3390
Date: 2012-04-14 13:12 +0200
http://bitbucket.org/pypy/pypy/changeset/a9db929b3390/
Log: a test for view_as_kwargs
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
@@ -889,6 +889,9 @@
return W_DictMultiObject.allocate_and_init_instance(
self, module=module, instance=instance)
+ def view_as_kwargs(self, w_d):
+ return w_d.view_as_kwargs() # assume it's a multidict
+
def finditem_str(self, w_dict, s):
return w_dict.getitem_str(s) # assume it's a multidict
diff --git a/pypy/objspace/std/test/test_kwargsdict.py
b/pypy/objspace/std/test/test_kwargsdict.py
--- a/pypy/objspace/std/test/test_kwargsdict.py
+++ b/pypy/objspace/std/test/test_kwargsdict.py
@@ -86,6 +86,19 @@
d = W_DictMultiObject(space, strategy, storage)
w_l = d.w_keys() # does not crash
+def test_view_as_kwargs():
+ from pypy.objspace.std.dictmultiobject import EmptyDictStrategy
+ strategy = KwargsDictStrategy(space)
+ keys = ["a", "b", "c"]
+ values = [1, 2, 3]
+ storage = strategy.erase((keys, values))
+ d = W_DictMultiObject(space, strategy, storage)
+ assert (space.view_as_kwargs(d) == keys, values)
+
+ strategy = EmptyDictStrategy(space)
+ storage = strategy.get_empty_storage()
+ d = W_DictMultiObject(space, strategy, storage)
+ assert (space.view_as_kwargs(d) == [], [])
from pypy.objspace.std.test.test_dictmultiobject import
BaseTestRDictImplementation, BaseTestDevolvedDictImplementation
def get_impl(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit