[3.13] gh-138584: Increase test coverage for collections.UserList (GH-138590) (#138611)

gh-138584: Increase test coverage for `collections.UserList` (GH-138590)

Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------
(cherry picked from commit d7b9ea5cab)

Co-authored-by: dbXD320 <devanshbaghla320@gmail.com>
Co-authored-by: Devansh Baghla <devanshbaghla34@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-09-07 11:52:35 +02:00 committed by GitHub
parent e5bbcb1605
commit 614c493406
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,13 +31,13 @@ def test_init(self):
self.assertEqual(a, b)
def test_getitem_error(self):
a = []
a = self.type2test([])
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
a['a']
def test_setitem_error(self):
a = []
a = self.type2test([])
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
a['a'] = "python"
@ -558,7 +558,7 @@ def test_constructor_exception_handling(self):
class F(object):
def __iter__(self):
raise KeyboardInterrupt
self.assertRaises(KeyboardInterrupt, list, F())
self.assertRaises(KeyboardInterrupt, self.type2test, F())
def test_exhausted_iterator(self):
a = self.type2test([1, 2, 3])