From: Robert Bradshaw Date: Tue, 23 Feb 2010 07:44:19 +0000 (-0800) Subject: Dict getitem test. X-Git-Tag: 0.13.beta0~319^2~25 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3f9ece17936649868c63b02a48f926ac6f19fb80;p=cython.git Dict getitem test. --- diff --git a/tests/run/dict_getitme.pyx b/tests/run/dict_getitme.pyx new file mode 100644 index 00000000..c43e5a24 --- /dev/null +++ b/tests/run/dict_getitme.pyx @@ -0,0 +1,25 @@ +def test(dict d, index): + """ + >>> d = { 1: 10 } + >>> test(d, 1) + 10 + + >>> test(d, 2) + Traceback (most recent call last): + ... + KeyError: 2 + + >>> test(d, (1,2)) + Traceback (most recent call last): + ... + KeyError: (1, 2) + + >>> class Unhashable: + ... def __hash__(self): + ... raise ValueError + >>> test(d, Unhashable()) + Traceback (most recent call last): + ... + ValueError + """ + return d[index]