Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: virtual-arguments Changeset: r54391:5041230ccf58 Date: 2012-04-14 10:44 +0200 http://bitbucket.org/pypy/pypy/changeset/5041230ccf58/
Log: a test that checks that the **args dict that is created is giving space.newdict the flag that turns it into a kwargsdict diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py --- a/pypy/interpreter/test/test_argument.py +++ b/pypy/interpreter/test/test_argument.py @@ -57,6 +57,9 @@ def __nonzero__(self): raise NotImplementedError +class kwargsdict(dict): + pass + class DummySpace(object): def newtuple(self, items): return tuple(items) @@ -79,6 +82,8 @@ return None, None def newdict(self, kwargs=False): + if kwargs: + return kwargsdict() return {} def newlist(self, l=[]): @@ -299,6 +304,22 @@ args._match_signature(None, l, Signature(["a", "b", "c"], None, "**")) assert l == [1, 2, 3, {'d': 4}] + def test_match_kwds_creates_kwdict(self): + space = DummySpace() + kwds = [("c", 3), ('d', 4)] + for i in range(4): + kwds_w = dict(kwds[:i]) + keywords = kwds_w.keys() + keywords_w = kwds_w.values() + w_kwds = dummy_wrapped_dict(kwds[i:]) + if i == 3: + w_kwds = None + args = Arguments(space, [1, 2], keywords, keywords_w, w_starstararg=w_kwds) + l = [None, None, None, None] + args._match_signature(None, l, Signature(["a", "b", "c"], None, "**")) + assert l == [1, 2, 3, {'d': 4}] + assert isinstance(l[-1], kwargsdict) + def test_duplicate_kwds(self): space = DummySpace() excinfo = py.test.raises(OperationError, Arguments, space, [], ["a"], _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit