[Python-checkins] python/dist/src/Lib/test test_heapq.py,1.7,1.8

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Thu Jun 10 01:03:19 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16530/Lib/test
Modified Files:
	test_heapq.py 
Log Message:
SF patch #969791: Add nlargest() and nsmallest() to heapq.
Index: test_heapq.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_heapq.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_heapq.py	7 Dec 2002 10:33:42 -0000	1.7
--- test_heapq.py	10 Jun 2004 05:03:17 -0000	1.8
***************
*** 3,7 ****
 from test.test_support import verify, vereq, verbose, TestFailed
 
! from heapq import heappush, heappop, heapify, heapreplace
 import random
 
--- 3,7 ----
 from test.test_support import verify, vereq, verbose, TestFailed
 
! from heapq import heappush, heappop, heapify, heapreplace, nlargest, nsmallest
 import random
 
***************
*** 85,88 ****
--- 85,97 ----
 sorted = [heappop(heap) for i in range(size)]
 vereq(data, sorted)
+ 
+ # 7) Check nlargest() and nsmallest()
+ data = [random.randrange(2000) for i in range(1000)]
+ copy = data[:]
+ copy.sort(reverse=True)
+ vereq(nlargest(data, 400), copy[:400])
+ copy.sort()
+ vereq(nsmallest(data, 400), copy[:400])
+ 
 # Make user happy
 if verbose:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /