diff options
Diffstat (limited to 'runtest.py')
-rw-r--r-- | runtest.py | 32 |
1 files changed, 27 insertions, 5 deletions
@@ -97,6 +97,31 @@ import time if not hasattr(os, 'WEXITSTATUS'): os.WEXITSTATUS = lambda x: x +try: + sorted +except NameError: + # Pre-2.4 Python has no sorted() function. + # + # The pre-2.4 Python list.sort() method does not support + # list.sort(key=) nor list.sort(reverse=) keyword arguments, so + # we must implement the functionality of those keyword arguments + # by hand instead of passing them to list.sort(). + def sorted(iterable, cmp=None, key=None, reverse=0): + if key is not None: + result = [(key(x), x) for x in iterable] + else: + result = iterable[:] + if cmp is None: + # Pre-2.3 Python does not support list.sort(None). + result.sort() + else: + result.sort(cmp) + if key is not None: + result = [t1 for t0,t1 in result] + if reverse: + result.reverse() + return result + cwd = os.getcwd() all = 0 @@ -619,9 +644,7 @@ if args: os.path.walk(path, find_Tests_py, tdict) elif path[:4] == 'test': os.path.walk(path, find_py, tdict) - t = tdict.keys() - t.sort() - tests.extend(t) + tests.extend(sorted(tdict.keys())) else: tests.append(path) elif testlistfile: @@ -658,8 +681,7 @@ elif all and not qmtest: elif a[-1] not in tdict: tdict[a[-1]] = Test(a[-1], spe) - tests = tdict.keys() - tests.sort() + tests = sorted(tdict.keys()) if qmtest: if baseline: |