Commit 40f1b2a2 authored by Stefan Behnel's avatar Stefan Behnel

extend test

Conflicts:
	tests/run/iterdict.pyx
parent 5d11b54e
......@@ -505,3 +505,53 @@ def values_of_expression(**kwargs):
"""
# this can be optimised even in Py2
return [ arg for arg in dict(kwargs.items()).values() ]
def items_of_expression(*args, **kwargs):
"""
>>> sorted(items_of_expression(a=3, b=4))
[('a', 3), ('b', 4)]
>>> sorted(items_of_expression([('a', 3)], b=4))
[('a', 3), ('b', 4)]
"""
return [item for item in dict(*args, **kwargs).items()]
def iteritems_of_expression(*args, **kwargs):
"""
>>> sorted(iteritems_of_expression(a=3, b=4))
[('a', 3), ('b', 4)]
>>> sorted(iteritems_of_expression([('a', 3)], b=4))
[('a', 3), ('b', 4)]
"""
return [item for item in dict(*args, **kwargs).iteritems()]
def for_in_items_of_expression(*args, **kwargs):
"""
>>> sorted(for_in_items_of_expression(a=3, b=4))
[('a', 3), ('b', 4)]
>>> sorted(for_in_items_of_expression([('a', 3)], b=4))
[('a', 3), ('b', 4)]
"""
result = []
for k, v in dict(*args, **kwargs).items():
result.append((k, v))
return result
def for_in_iteritems_of_expression(*args, **kwargs):
"""
>>> sorted(for_in_iteritems_of_expression(a=3, b=4))
[('a', 3), ('b', 4)]
>>> sorted(for_in_iteritems_of_expression([('a', 3)], b=4))
[('a', 3), ('b', 4)]
"""
result = []
for k, v in dict(*args, **kwargs).iteritems():
result.append((k, v))
return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment