[Python-checkins] python/dist/src/Lib/test list_tests.py,1.5,1.6
doerwalter at users.sourceforge.net
doerwalter at users.sourceforge.net
Mon Mar 21 22:31:49 CET 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23804/Lib/test
Modified Files:
list_tests.py
Log Message:
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)
Index: list_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/list_tests.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- list_tests.py 30 Sep 2004 07:47:20 -0000 1.5
+++ list_tests.py 21 Mar 2005 21:31:47 -0000 1.6
@@ -309,6 +309,26 @@
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)
More information about the Python-checkins
mailing list