add tests for non-loop usage of dict.iter*() methods
authorStefan Behnel <stefan_ml@behnel.de>
Thu, 21 Feb 2013 20:56:53 +0000 (21:56 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Thu, 21 Feb 2013 20:56:53 +0000 (21:56 +0100)
tests/run/iterdict.pyx

index 2acdde9..d8c56f1 100644 (file)
@@ -4,6 +4,40 @@ cimport cython
 dict_size = 4
 d = dict(zip(range(10,dict_size+10), range(dict_size)))
 
+
+def dict_iteritems(dict d):
+    """
+    >>> it = dict_iteritems(d)
+    >>> type(it) is list
+    False
+    >>> sorted(it)
+    [(10, 0), (11, 1), (12, 2), (13, 3)]
+    """
+    return d.iteritems()
+
+
+def dict_iterkeys(dict d):
+    """
+    >>> it = dict_iterkeys(d)
+    >>> type(it) is list
+    False
+    >>> sorted(it)
+    [10, 11, 12, 13]
+    """
+    return d.iterkeys()
+
+
+def dict_itervalues(dict d):
+    """
+    >>> it = dict_itervalues(d)
+    >>> type(it) is list
+    False
+    >>> sorted(it)
+    [0, 1, 2, 3]
+    """
+    return d.itervalues()
+
+
 @cython.test_fail_if_path_exists(
     "//WhileStatNode")
 def items(dict d):