From 3f9ece17936649868c63b02a48f926ac6f19fb80 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 22 Feb 2010 23:44:19 -0800 Subject: [PATCH] Dict getitem test. --- tests/run/dict_getitme.pyx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/run/dict_getitme.pyx 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] -- 2.26.2