From 624eff6a8a948c5ffa7c7d17fab69b3739f2e711 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 10 Feb 2014 06:42:20 +0200 Subject: Implement tuple.index(). --- tests/basics/tuple_index.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/basics/tuple_index.py (limited to 'tests/basics/tuple_index.py') diff --git a/tests/basics/tuple_index.py b/tests/basics/tuple_index.py new file mode 100644 index 000000000..1aef100d7 --- /dev/null +++ b/tests/basics/tuple_index.py @@ -0,0 +1,24 @@ +a = (1, 2, 3) +print(a.index(1)) +print(a.index(2)) +print(a.index(3)) +print(a.index(3, 2)) +try: + print(a.index(3, 2, 2)) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") + +a = a + a +b = (0, 0, a) +print(a.index(2)) +print(b.index(a)) +print(a.index(2, 2)) + +try: + a.index(2, 2, 2) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") -- cgit v1.2.3