[Python-checkins] python/dist/src/Lib/test test_sort.py,1.3,1.4

montanaro@users.sourceforge.net montanaro@users.sourceforge.net
2003年1月02日 12:51:37 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv5845/Lib/test
Modified Files:
	test_sort.py 
Log Message:
Allow list sort's comparison function to explicitly be None. See SF patch
661092.
Index: test_sort.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sort.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_sort.py	12 Nov 2002 22:08:08 -0000	1.3
--- test_sort.py	2 Jan 2003 20:51:04 -0000	1.4
***************
*** 146,149 ****
--- 146,169 ----
 bug453523()
 
+ def cmpNone():
+ global nerrors
+ 
+ if verbose:
+ print "Testing None as a comparison function."
+ 
+ L = range(50)
+ random.shuffle(L)
+ try:
+ L.sort(None)
+ except TypeError:
+ print " Passing None as cmpfunc failed."
+ nerrors += 1
+ else:
+ if L != range(50):
+ print " Passing None as cmpfunc failed."
+ nerrors += 1
+ 
+ cmpNone()
+ 
 if nerrors:
 print "Test failed", nerrors

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