Skip to content

Commit b60808a

Browse files
cclaussBethGriggs
authored andcommitted
tools: prepare tools/testp.py for Python 3
PR-URL: #24890 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent bf4faf3 commit b60808a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎tools/test.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,26 @@
4444
importmultiprocessing
4545
importerrno
4646
importcopy
47-
importast
4847

4948
fromos.pathimportjoin, dirname, abspath, basename, isdir, exists
5049
fromdatetimeimportdatetime
5150
fromQueueimportQueue, Empty
5251

5352
try:
54-
reduce# Python 2
53+
cmp# Python 2
54+
exceptNameError:
55+
defcmp(x, y): # Python 3
56+
return (x>y) - (x<y)
57+
58+
try:
59+
reduce# Python 2
5560
exceptNameError: # Python 3
5661
fromfunctoolsimportreduce
5762

5863
try:
59-
xrange# Python 2
64+
xrange# Python 2
6065
exceptNameError:
61-
xrange=range# Python 3
66+
xrange=range# Python 3
6267

6368
logger=logging.getLogger('testrunner')
6469
skip_regex=re.compile(r'# SKIP\S*\s+(.*)', re.IGNORECASE)

0 commit comments

Comments
 (0)