Skip to content

Commit a5c8af7

Browse files
cclaussMylesBorins
cclauss
authored andcommitted
test: prepare test/message/testcfg.py for Python 3
PR-URL: #24793 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 022599c commit a5c8af7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/message/testcfg.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
from os.path import join, exists, basename, isdir
3232
import re
3333

34+
try:
35+
reduce # Python 2
36+
except NameError: # Python 3
37+
from functools import reduce
38+
39+
try:
40+
xrange # Python 2
41+
except NameError:
42+
xrange = range # Python 3
43+
3444
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
3545

3646
class MessageTestCase(test.TestCase):
@@ -49,7 +59,7 @@ def IgnoreLine(self, str):
4959
else: return str.startswith('==') or str.startswith('**')
5060

5161
def IsFailureOutput(self, output):
52-
f = file(self.expected)
62+
f = open(self.expected)
5363
# Skip initial '#' comment and spaces
5464
#for line in f:
5565
# if (not line.startswith('#')) and (not line.strip()):

0 commit comments

Comments
 (0)