diff options
author | Skip Montanaro <skip@pobox.com> | 2003-01-02 20:51:08 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2003-01-02 20:51:08 (GMT) |
commit | 4abd5f0fce54d32fbe01207e505047bd82ff9ca3 (patch) | |
tree | 7c94a45859968c9e92cf2c5970ee2d4071a9b7a8 /Lib/test/test_sort.py | |
parent | fe8496ca03e93b74fe007de50f0e05347a772a60 (diff) | |
download | cpython-4abd5f0fce54d32fbe01207e505047bd82ff9ca3.zip cpython-4abd5f0fce54d32fbe01207e505047bd82ff9ca3.tar.gz cpython-4abd5f0fce54d32fbe01207e505047bd82ff9ca3.tar.bz2 |
Allow list sort's comparison function to explicitly be None. See SF patch
661092.
Diffstat (limited to 'Lib/test/test_sort.py')
-rw-r--r-- | Lib/test/test_sort.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py index 5c7ae88..6c35f42 100644 --- a/Lib/test/test_sort.py +++ b/Lib/test/test_sort.py @@ -145,6 +145,26 @@ def bug453523(): 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 elif verbose: |