diff options
author | Walter Dörwald <walter@livinglogic.de> | 2005-03-21 21:31:47 +0000 |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2005-03-21 21:31:47 +0000 |
commit | e5fb0fc163301efa37dd85a1e1dea0dd8708d71b (patch) | |
tree | 247beec183d0ccde5d2e2b791fe194de215e265e /Lib/test/list_tests.py | |
parent | 0b9064d8bfcbd38c84fa7e737085079aeeb4a7f8 (diff) | |
download | cpython-e5fb0fc163301efa37dd85a1e1dea0dd8708d71b.tar.gz |
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.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index e616c79fb5..284edb39c3 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) |