diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-03-27 07:39:52 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-03-27 07:39:52 (GMT) |
commit | 59ed0a109bf5add2efcef459080837b11066c6fb (patch) | |
tree | fff879b4f9676a72e16c0f7b4dd969f050038b4f /runtest.py | |
parent | 00a3188193ba1feef927cf18e7f5fc20ad71b848 (diff) | |
download | SCons-59ed0a109bf5add2efcef459080837b11066c6fb.zip SCons-59ed0a109bf5add2efcef459080837b11066c6fb.tar.gz SCons-59ed0a109bf5add2efcef459080837b11066c6fb.tar.bz2 |
http://scons.tigris.org/issues/show_bug.cgi?id=2329
Applied a number of idiomatic changes.
Uses of the 'sort()' method were converted into calls of 'sorted()' when
possible and the sorted() expression was inserted into a subsequent statement
whenever that made sense.
The statement 'while 1:' was changed to 'while True:'.
Names from the 'types' module (e.g., 'types.FooType') were converted to the
equivalent build-in type (e.g., 'foo').
Comparisons between types were changed to use 'isinstance()'.
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: |