[Python-checkins] python/dist/src/Lib/test test_types.py,1.52,1.53 test_userlist.py,1.9,1.10

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Mon, 16 Jun 2003 22:05:51 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv30555/Lib/test

Modified Files:
	test_types.py test_userlist.py 
Log Message:
SF #754014:  list.index() should accept optional start, end arguments

Also, modified UserList.index() to match and expanded the related tests.



Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** test_types.py	12 May 2003 20:19:37 -0000	1.52
--- test_types.py	17 Jun 2003 05:05:49 -0000	1.53
***************
*** 367,371 ****
--- 367,387 ----
  if a.count(0) != 2: raise TestFailed, ' list count'
  if a.index(0) != 2: raise TestFailed, 'list index'
+ if a.index(0,2) != 2: raise TestFailed, 'list index, start argument'
+ if a.index(-2,-10) != 0: raise TestFailed, 'list index, negative start argument'
+ if a.index(0,3) != 3: raise TestFailed, 'list index, start argument'
+ if a.index(0,3,4) != 3: raise TestFailed, 'list index, stop argument'
+ try:
+     a.index(2,0,-10)
+ except ValueError:
+     pass
+ else:
+     raise TestFailed, 'list index, negative stop argument'
  a.remove(0)
+ try:
+     a.index(2,0,4)
+ except ValueError:
+     pass
+ else:
+     raise TestFailed, 'list index, stop argument.'
  if a != [-2,-1,0,1,2]: raise TestFailed, 'list remove'
  a.reverse()

Index: test_userlist.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userlist.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_userlist.py	1 May 2003 17:45:54 -0000	1.9
--- test_userlist.py	17 Jun 2003 05:05:49 -0000	1.10
***************
*** 207,210 ****
--- 207,219 ----
          self.assertRaises(ValueError, u.index, 2)
  
+         u = UserList([-2,-1,0,0,1,2])
+         self.assertEqual(u.count(0), 2)
+         self.assertEqual(u.index(0), 2)
+         self.assertEqual(u.index(0,2), 2)
+         self.assertEqual(u.index(-2,-10), 0)
+         self.assertEqual(u.index(0,3), 3)
+         self.assertEqual(u.index(0,3,4), 3)
+         self.assertRaises(ValueError, u.index, 2,0,-10)
+ 
      def test_reverse(self):
          u = UserList((0, 1))