gh-138584: Increase test coverage for collections.UserList (#138590)
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>
This commit is contained in:
@@ -32,13 +32,13 @@ class CommonTest(seq_tests.CommonTest):
|
|||||||
self.assertEqual(a, b)
|
self.assertEqual(a, b)
|
||||||
|
|
||||||
def test_getitem_error(self):
|
def test_getitem_error(self):
|
||||||
a = []
|
a = self.type2test([])
|
||||||
msg = "list indices must be integers or slices"
|
msg = "list indices must be integers or slices"
|
||||||
with self.assertRaisesRegex(TypeError, msg):
|
with self.assertRaisesRegex(TypeError, msg):
|
||||||
a['a']
|
a['a']
|
||||||
|
|
||||||
def test_setitem_error(self):
|
def test_setitem_error(self):
|
||||||
a = []
|
a = self.type2test([])
|
||||||
msg = "list indices must be integers or slices"
|
msg = "list indices must be integers or slices"
|
||||||
with self.assertRaisesRegex(TypeError, msg):
|
with self.assertRaisesRegex(TypeError, msg):
|
||||||
a['a'] = "python"
|
a['a'] = "python"
|
||||||
@@ -561,7 +561,7 @@ class CommonTest(seq_tests.CommonTest):
|
|||||||
class F(object):
|
class F(object):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt
|
||||||
self.assertRaises(KeyboardInterrupt, list, F())
|
self.assertRaises(KeyboardInterrupt, self.type2test, F())
|
||||||
|
|
||||||
def test_exhausted_iterator(self):
|
def test_exhausted_iterator(self):
|
||||||
a = self.type2test([1, 2, 3])
|
a = self.type2test([1, 2, 3])
|
||||||
|
|||||||
Reference in New Issue
Block a user