summaryrefslogtreecommitdiffstats
path: root/Lib/test/list_tests.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2005-03-21 21:31:47 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2005-03-21 21:31:47 (GMT)
commit7355e8133d3b03b11fd3d3b1d83e071c5fd9873e (patch)
treeabdf83b76bfcc3f1e3389f88dcee534545f5bf62 /Lib/test/list_tests.py
parent98858c9efd37321ed5f05202e597f4469f15c7c2 (diff)
downloadcpython-7355e8133d3b03b11fd3d3b1d83e071c5fd9873e.zip
cpython-7355e8133d3b03b11fd3d3b1d83e071c5fd9873e.tar.gz
cpython-7355e8133d3b03b11fd3d3b1d83e071c5fd9873e.tar.bz2
Add list tests that ensure that remove() removes the first occurrence.
(Copied from test_deque.py as suggested by Jim Jewett in SF bug #1166274)
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r--Lib/test/list_tests.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index e616c79..284edb3 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -309,6 +309,26 @@ class CommonTest(seq_tests.CommonTest):
a = self.type2test([0, 1, 2, 3])
self.assertRaises(BadExc, a.remove, BadCmp())
+ class BadCmp2:
+ def __eq__(self, other):
+ raise BadExc()
+
+ d = self.type2test('abcdefghcij')
+ d.remove('c')
+ self.assertEqual(d, self.type2test('abdefghcij'))
+ d.remove('c')
+ self.assertEqual(d, self.type2test('abdefghij'))
+ self.assertRaises(ValueError, d.remove, 'c')
+ self.assertEqual(d, self.type2test('abdefghij'))
+
+ # Handle comparison errors
+ d = self.type2test(['a', 'b', BadCmp2(), 'c'])
+ e = self.type2test(d)
+ self.assertRaises(BadExc, d.remove, 'c')
+ for x, y in zip(d, e):
+ # verify that original order and values are retained.
+ self.assert_(x is y)
+
def test_count(self):
a = self.type2test([0, 1, 2])*3
self.assertEqual(a.count(0), 3)