[Python-checkins] python/dist/src/Lib/test test_bisect.py,1.9,1.10

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Mon Jan 5 05:13:36 EST 2004


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

Modified Files:
	test_bisect.py 
Log Message:
SF Patch #864863:  Bisect C implementation
(Contributed by Dmitry Vasiliev.)



Index: test_bisect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bisect.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_bisect.py	1 May 2003 17:45:32 -0000	1.9
--- test_bisect.py	5 Jan 2004 10:13:34 -0000	1.10
***************
*** 2,5 ****
--- 2,6 ----
  from test import test_support
  from bisect import bisect_right, bisect_left, insort_left, insort_right, insort, bisect
+ from UserList import UserList
  
  class TestBisect(unittest.TestCase):
***************
*** 90,93 ****
--- 91,95 ----
          for func, data, elem, expected in self.precomputedCases:
              self.assertEqual(func(data, elem), expected)
+             self.assertEqual(func(UserList(data), elem), expected)
  
      def test_random(self, n=25):
***************
*** 133,152 ****
  class TestInsort(unittest.TestCase):
  
!     def test_vsListSort(self, n=500):
          from random import choice
!         digits = "0123456789"
!         raw = []
!         insorted = []
!         for i in range(n):
!             digit = choice(digits)
!             raw.append(digit)
!             if digit in "02468":
!                 f = insort_left
!             else:
!                 f = insort_right
!             f(insorted, digit)
!         sorted = raw[:]
!         sorted.sort()
!         self.assertEqual(sorted, insorted)
  
      def test_backcompatibility(self):
--- 135,149 ----
  class TestInsort(unittest.TestCase):
  
!     def test_vsBuiltinSort(self, n=500):
          from random import choice
!         for insorted in (list(), UserList()):
!             for i in xrange(n):
!                 digit = choice("0123456789")
!                 if digit in "02468":
!                     f = insort_left
!                 else:
!                     f = insort_right
!                 f(insorted, digit)
!         self.assertEqual(sorted(insorted), insorted)
  
      def test_backcompatibility(self):





More information about the Python-checkins mailing list