[Python-checkins] python/dist/src/Lib/test test_heapq.py,1.10,1.11

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun Jun 13 01:26:35 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5574/Lib/test

Modified Files:
	test_heapq.py 
Log Message:
Install C version of heapq.nsmallest().

Index: test_heapq.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_heapq.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_heapq.py	12 Jun 2004 08:33:36 -0000	1.10
--- test_heapq.py	13 Jun 2004 05:26:33 -0000	1.11
***************
*** 5,8 ****
--- 5,9 ----
  import unittest
  from test import test_support
+ import sys
  
  
***************
*** 92,106 ****
      def test_nsmallest(self):
          data = [random.randrange(2000) for i in range(1000)]
!         self.assertEqual(nsmallest(data, 400), sorted(data)[:400])
!         self.assertEqual(nsmallest(data, 50), sorted(data)[:50])
  
      def test_largest(self):
          data = [random.randrange(2000) for i in range(1000)]
!         self.assertEqual(nlargest(data, 400), sorted(data, reverse=True)[:400])
  
! def test_main():
!     test_support.run_unittest(TestHeap)
  
  if __name__ == "__main__":
!     test_main()
  
--- 93,119 ----
      def test_nsmallest(self):
          data = [random.randrange(2000) for i in range(1000)]
!         for i in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
!             self.assertEqual(nsmallest(data, i), sorted(data)[:i])
  
      def test_largest(self):
          data = [random.randrange(2000) for i in range(1000)]
!         for i in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
!             self.assertEqual(nlargest(data, i), sorted(data, reverse=True)[:i])
  
! def test_main(verbose=None):
!     test_classes = [TestHeap]
!     test_support.run_unittest(*test_classes)
! 
!     # verify reference counting
!     if verbose and hasattr(sys, "gettotalrefcount"):
!         import gc
!         counts = [None] * 5
!         for i in xrange(len(counts)):
!             test_support.run_unittest(*test_classes)
!             gc.collect()
!             counts[i] = sys.gettotalrefcount()
!         print counts
  
  if __name__ == "__main__":
!     test_main(verbose=True)
  




More information about the Python-checkins mailing list