[Python-checkins] python/dist/src/Lib/test test_types.py,1.31,1.32

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Thu, 13 Jun 2002 15:23:08 -0700


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

Modified Files:
	test_types.py 
Log Message:
Test exceptional conditions in list.sort()

Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** test_types.py	11 Jun 2002 13:38:42 -0000	1.31
--- test_types.py	13 Jun 2002 22:23:06 -0000	1.32
***************
*** 354,357 ****
--- 354,372 ----
  z.sort(myComparison)
  
+ try: z.sort(2)
+ except TypeError: pass
+ else: raise TestFailed, 'list sort compare function is not callable'
+ 
+ def selfmodifyingComparison(x,y):
+     z[0] = 1
+     return cmp(x, y)
+ try: z.sort(selfmodifyingComparison)
+ except TypeError: pass
+ else: raise TestFailed, 'modifying list during sort'
+ 
+ try: z.sort(lambda x, y: 's')
+ except TypeError: pass
+ else: raise TestFailed, 'list sort compare function does not return int'
+ 
  # Test extreme cases with long ints
  a = [0,1,2,3,4]