diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-08-02 05:30:37 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-08-02 05:30:37 (GMT) |
commit | ffff1440d118cae189a6c2baf595dda52cdc7c3a (patch) | |
tree | e1664353a0276044933c16879fa59e7521a6044e /Lib/test/list_tests.py | |
parent | 7f9cc9359bdbcc877b2a6f976c8e8bdbc714ce90 (diff) | |
download | cpython-ffff1440d118cae189a6c2baf595dda52cdc7c3a.zip cpython-ffff1440d118cae189a6c2baf595dda52cdc7c3a.tar.gz cpython-ffff1440d118cae189a6c2baf595dda52cdc7c3a.tar.bz2 |
Issue #22077: Improve index error messages for bytearrays, bytes, lists, and
tuples by adding 'or slices'. Added ', not <typename' for bytearrays.
Original patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r-- | Lib/test/list_tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index 42e118b..9069337 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] |