summaryrefslogtreecommitdiff
path: root/Lib/test/list_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r--Lib/test/list_tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index 42e118ba8f..906933796d 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -30,6 +30,12 @@ class CommonTest(seq_tests.CommonTest):
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
+ def test_getitem_error(self):
+ msg = "list indices must be integers or slices"
+ with self.assertRaisesRegex(TypeError, msg):
+ a = []
+ a['a'] = "python"
+
def test_repr(self):
l0 = []
l2 = [0, 1, 2]
@@ -120,6 +126,10 @@ class CommonTest(seq_tests.CommonTest):
a[-1] = 9
self.assertEqual(a, self.type2test([5,6,7,8,9]))
+ msg = "list indices must be integers or slices"
+ with self.assertRaisesRegex(TypeError, msg):
+ a['a'] = "python"
+
def test_delitem(self):
a = self.type2test([0, 1])
del a[1]