From b1bbac726e9c25a00ef2a601cbcf24f26dad4d1e Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 3 Dec 2018 09:57:54 +0100 Subject: [PATCH] test: prepare test/message/testcfg.py for Python 3 PR-URL: https://github.com/nodejs/node/pull/24793 Reviewed-By: Rich Trott Reviewed-By: Richard Lau --- test/message/testcfg.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/message/testcfg.py b/test/message/testcfg.py index 62776bcb7af0e2..a4f802f3efc584 100644 --- a/test/message/testcfg.py +++ b/test/message/testcfg.py @@ -31,6 +31,16 @@ from os.path import join, exists, basename, isdir import re +try: + reduce # Python 2 +except NameError: # Python 3 + from functools import reduce + +try: + xrange # Python 2 +except NameError: + xrange = range # Python 3 + FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") class MessageTestCase(test.TestCase): @@ -49,7 +59,7 @@ def IgnoreLine(self, str): else: return str.startswith('==') or str.startswith('**') def IsFailureOutput(self, output): - f = file(self.expected) + f = open(self.expected) # Skip initial '#' comment and spaces #for line in f: # if (not line.startswith('#')) and (not line.strip()):