]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-138584: Increase test coverage for `collections.UserList` (#138590)
authordbXD320 <devanshbaghla320@gmail.com>
Sun, 7 Sep 2025 08:53:22 +0000 (14:23 +0530)
committerGitHub <noreply@github.com>
Sun, 7 Sep 2025 08:53:22 +0000 (10:53 +0200)
Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------

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

index 68d6bad2094268a9e70687a97917e6c013a4640d..e76f79c274e744a990e14721443a431ab1c131a3 100644 (file)
@@ -32,13 +32,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"
@@ -561,7 +561,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])