diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-13 22:23:06 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-13 22:23:06 (GMT) |
commit | 6fc36c549183860ba4b1b83cd34a47a51881f8db (patch) | |
tree | 06ce764d1478489b569874b5b173c5410896f910 /Lib/test | |
parent | 2b3429005517673ee5903d4030990ee2b5c29171 (diff) | |
download | cpython-6fc36c549183860ba4b1b83cd34a47a51881f8db.zip cpython-6fc36c549183860ba4b1b83cd34a47a51881f8db.tar.gz cpython-6fc36c549183860ba4b1b83cd34a47a51881f8db.tar.bz2 |
Test exceptional conditions in list.sort()
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_types.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 71e18c4..7f3b923 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -353,6 +353,21 @@ def myComparison(x,y): z = range(12) 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] if a[ -pow(2,128L): 3 ] != [0,1,2]: |