From b02f373a4d79e7bfaf7dae01986e5d37cda73193 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 21 Feb 2013 21:56:53 +0100 Subject: [PATCH] add tests for non-loop usage of dict.iter*() methods --- tests/run/iterdict.pyx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/run/iterdict.pyx b/tests/run/iterdict.pyx index 2acdde9..d8c56f1 100644 --- a/tests/run/iterdict.pyx +++ b/tests/run/iterdict.pyx @@ -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): -- 2.7.4