Skip to content

Commit 87f2082

Browse files
cclaussBethGriggs
cclauss
authored andcommitted
tools: prepare tools/testp.py for Python 3
PR-URL: #24890 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent f2287c6 commit 87f2082

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/test.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,26 @@
4444
import multiprocessing
4545
import errno
4646
import copy
47-
import ast
4847

4948
from os.path import join, dirname, abspath, basename, isdir, exists
5049
from datetime import datetime
5150
from Queue import Queue, Empty
5251

5352
try:
54-
reduce # Python 2
53+
cmp # Python 2
54+
except NameError:
55+
def cmp(x, y): # Python 3
56+
return (x > y) - (x < y)
57+
58+
try:
59+
reduce # Python 2
5560
except NameError: # Python 3
5661
from functools import reduce
5762

5863
try:
59-
xrange # Python 2
64+
xrange # Python 2
6065
except NameError:
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)