From: Stefan Behnel Date: Thu, 1 Apr 2010 18:34:59 +0000 (+0200) Subject: extended test cases X-Git-Tag: 0.13.beta0~246 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6db166890bcc0a880248ef390dbacfcaa1e9967a;p=cython.git extended test cases --- diff --git a/tests/run/dict_get.pyx b/tests/run/dict_get.pyx index f27a8137..d5d905e5 100644 --- a/tests/run/dict_get.pyx +++ b/tests/run/dict_get.pyx @@ -1,3 +1,8 @@ + +cimport cython + +@cython.test_assert_path_exists("//PythonCapiCallNode") +@cython.test_fail_if_path_exists("//AttributeNode") def get(dict d, key): """ >>> d = { 1: 10 } @@ -38,6 +43,9 @@ def get(dict d, key): """ return d.get(key) + +@cython.test_assert_path_exists("//PythonCapiCallNode") +@cython.test_fail_if_path_exists("//AttributeNode") def get_default(dict d, key, default): """ >>> d = { 1: 10 } @@ -69,3 +77,14 @@ def get_default(dict d, key, default): ValueError """ return d.get(key, default) + + +@cython.test_assert_path_exists("//PythonCapiCallNode") +@cython.test_fail_if_path_exists("//AttributeNode") +def get_in_condition(dict d, key, expected_result): + """ + >>> d = dict(a=1, b=2) + >>> getitem_in_condition(d, 'a', 1) + True + """ + return d.get(key) is expected_result diff --git a/tests/run/dict_getitem.pyx b/tests/run/dict_getitem.pyx index b4673d6c..f40c31b8 100644 --- a/tests/run/dict_getitem.pyx +++ b/tests/run/dict_getitem.pyx @@ -32,3 +32,12 @@ def test(dict d, index): cdef class Subscriptable: def __getitem__(self, key): return key + + +def getitem_in_condition(dict d, key, expected_result): + """ + >>> d = dict(a=1, b=2) + >>> getitem_in_condition(d, 'a', 1) + True + """ + return d[key] is expected_result