]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-138584: Increase test coverage for `collections.UserList` (GH-138590) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 7 Sep 2025 09:52:35 +0000 (11:52 +0200)
committerGitHub <noreply@github.com>
Sun, 7 Sep 2025 09:52:35 +0000 (09:52 +0000)
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 d7b9ea5cab984497526fcc0b988e4eb5988c1e88)

Co-authored-by: dbXD320 <devanshbaghla320@gmail.com>
Co-authored-by: Devansh Baghla <devanshbaghla34@gmail.com>
Lib/test/list_tests.py

index dbc5ef4f9f2cd50886a8342745e92ae5dd5e20ab..65dfa41b26e9659e59f235a546ddcf22923a52cd 100644 (file)
@@ -31,13 +31,13 @@ class CommonTest(seq_tests.CommonTest):
         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 @@ class CommonTest(seq_tests.CommonTest):
         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])