diff options
author | Refael Ackermann <refack@gmail.com> | 2019-04-13 18:09:45 -0400 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2019-04-13 20:33:06 -0400 |
commit | 1fc425522192bb66292104dc5cf6fd8e05cb2146 (patch) | |
tree | 55d5abd1b8b6692661269cd4c7f8249faf1b49a8 /test | |
parent | a16a0fe9629325ae1dd81827c6071ca972d7449a (diff) | |
download | android-node-v8-1fc425522192bb66292104dc5cf6fd8e05cb2146.tar.gz android-node-v8-1fc425522192bb66292104dc5cf6fd8e05cb2146.tar.bz2 android-node-v8-1fc425522192bb66292104dc5cf6fd8e05cb2146.zip |
tools: python: ignore instead of select flake8 rules
PR-URL: https://github.com/nodejs/node/pull/25614
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/message/testcfg.py | 25 | ||||
-rw-r--r-- | test/pseudo-tty/testcfg.py | 41 | ||||
-rw-r--r-- | test/testpy/__init__.py | 44 |
3 files changed, 43 insertions, 67 deletions
diff --git a/test/message/testcfg.py b/test/message/testcfg.py index a4f802f3ef..bd56a8eba8 100644 --- a/test/message/testcfg.py +++ b/test/message/testcfg.py @@ -30,16 +30,7 @@ import test import os 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 +from functools import reduce FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") @@ -82,13 +73,13 @@ class MessageTestCase(test.TestCase): print("expect=%d" % len(patterns)) print("actual=%d" % len(outlines)) print("patterns:") - for i in xrange(len(patterns)): + for i in range(len(patterns)): print("pattern = %s" % patterns[i]) print("outlines:") - for i in xrange(len(outlines)): + for i in range(len(outlines)): print("outline = %s" % outlines[i]) return True - for i in xrange(len(patterns)): + for i in range(len(patterns)): if not re.match(patterns[i], outlines[i]): print("match failed") print("line=%d" % i) @@ -129,13 +120,13 @@ class MessageTestConfiguration(test.TestConfiguration): def ListTests(self, current_path, path, arch, mode): all_tests = [current_path + [t] for t in self.Ls(self.root)] result = [] - for test in all_tests: - if self.Contains(path, test): - file_path = join(self.root, reduce(join, test[1:], '')) + for tst in all_tests: + if self.Contains(path, tst): + file_path = join(self.root, reduce(join, tst[1:], '')) output_path = file_path[:file_path.rfind('.')] + '.out' if not exists(output_path): raise Exception("Could not find %s" % output_path) - result.append(MessageTestCase(test, file_path, output_path, + result.append(MessageTestCase(tst, file_path, output_path, arch, mode, self.context, self)) return result diff --git a/test/pseudo-tty/testcfg.py b/test/pseudo-tty/testcfg.py index c12a16f805..f2a7242e83 100644 --- a/test/pseudo-tty/testcfg.py +++ b/test/pseudo-tty/testcfg.py @@ -32,34 +32,25 @@ import os from os.path import join, exists, basename, isdir import re import utils - -try: - reduce # Python 2 -except NameError: # Python 3 - from functools import reduce - -try: - xrange # Python 2 -except NameError: - xrange = range # Python 3 +from functools import reduce FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") class TTYTestCase(test.TestCase): - def __init__(self, path, file, expected, input, arch, mode, context, config): + def __init__(self, path, file, expected, input_arg, arch, mode, context, config): super(TTYTestCase, self).__init__(context, path, arch, mode) self.file = file self.expected = expected - self.input = input + self.input = input_arg self.config = config self.arch = arch self.mode = mode - def IgnoreLine(self, str): + def IgnoreLine(self, str_arg): """Ignore empty lines and valgrind output.""" - if not str.strip(): return True - else: return str.startswith('==') or str.startswith('**') + if not str_arg.strip(): return True + else: return str_arg.startswith('==') or str_arg.startswith('**') def IsFailureOutput(self, output): f = open(self.expected) @@ -81,13 +72,13 @@ class TTYTestCase(test.TestCase): print("expect=%d" % len(patterns)) print("actual=%d" % len(outlines)) print("patterns:") - for i in xrange(len(patterns)): + for i in range(len(patterns)): print("pattern = %s" % patterns[i]) print("outlines:") - for i in xrange(len(outlines)): + for i in range(len(outlines)): print("outline = %s" % outlines[i]) return True - for i in xrange(len(patterns)): + for i in range(len(patterns)): if not re.match(patterns[i], outlines[i]): print("match failed") print("line=%d" % i) @@ -117,16 +108,16 @@ class TTYTestCase(test.TestCase): + open(self.expected).read()) def RunCommand(self, command, env): - input = None + input_arg = None if self.input is not None and exists(self.input): - input = open(self.input).read() + input_arg = open(self.input).read() full_command = self.context.processor(command) output = test.Execute(full_command, self.context, self.context.GetTimeout(self.mode), env, faketty=True, - input=input) + input=input_arg) return test.TestOutput(self, full_command, output, @@ -148,15 +139,15 @@ class TTYTestConfiguration(test.TestConfiguration): print ("Skipping pseudo-tty tests, as pseudo terminals are not available" " on Windows.") return result - for test in all_tests: - if self.Contains(path, test): - file_prefix = join(self.root, reduce(join, test[1:], "")) + for tst in all_tests: + if self.Contains(path, tst): + file_prefix = join(self.root, reduce(join, tst[1:], "")) file_path = file_prefix + ".js" input_path = file_prefix + ".in" output_path = file_prefix + ".out" if not exists(output_path): raise Exception("Could not find %s" % output_path) - result.append(TTYTestCase(test, file_path, output_path, + result.append(TTYTestCase(tst, file_path, output_path, input_path, arch, mode, self.context, self)) return result diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 332284ce4c..9c70e18d6a 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -27,18 +27,12 @@ import test import os -from os.path import join, dirname, exists, splitext import re -import ast - -try: - reduce -except NameError: - from functools import reduce +from functools import reduce FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") - +LS_RE = re.compile(r'^test-.*\.m?js$') class SimpleTestCase(test.TestCase): @@ -107,15 +101,15 @@ class SimpleTestConfiguration(test.TestConfiguration): self.additional_flags = [] def Ls(self, path): - return [f for f in os.listdir(path) if re.match('^test-.*\.m?js$', f)] + return [f for f in os.listdir(path) if LS_RE.match(f)] def ListTests(self, current_path, path, arch, mode): - all_tests = [current_path + [t] for t in self.Ls(join(self.root))] + all_tests = [current_path + [t] for t in self.Ls(os.path.join(self.root))] result = [] - for test in all_tests: - if self.Contains(path, test): - file_path = join(self.root, reduce(join, test[1:], "")) - test_name = test[:-1] + [splitext(test[-1])[0]] + for tst in all_tests: + if self.Contains(path, tst): + file_path = os.path.join(self.root, reduce(os.path.join, tst[1:], "")) + test_name = tst[:-1] + [os.path.splitext(tst[-1])[0]] result.append(SimpleTestCase(test_name, file_path, arch, mode, self.context, self, self.additional_flags)) return result @@ -131,8 +125,8 @@ class ParallelTestConfiguration(SimpleTestConfiguration): def ListTests(self, current_path, path, arch, mode): result = super(ParallelTestConfiguration, self).ListTests( current_path, path, arch, mode) - for test in result: - test.parallel = True + for tst in result: + tst.parallel = True return result class AddonTestConfiguration(SimpleTestConfiguration): @@ -145,20 +139,20 @@ class AddonTestConfiguration(SimpleTestConfiguration): result = [] for subpath in os.listdir(path): - if os.path.isdir(join(path, subpath)): - for f in os.listdir(join(path, subpath)): + if os.path.isdir(os.path.join(path, subpath)): + for f in os.listdir(os.path.join(path, subpath)): if SelectTest(f): result.append([subpath, f[:-3]]) return result def ListTests(self, current_path, path, arch, mode): - all_tests = [current_path + t for t in self.Ls(join(self.root))] + all_tests = [current_path + t for t in self.Ls(os.path.join(self.root))] result = [] - for test in all_tests: - if self.Contains(path, test): - file_path = join(self.root, reduce(join, test[1:], "") + ".js") + for tst in all_tests: + if self.Contains(path, tst): + file_path = os.path.join(self.root, reduce(os.path.join, tst[1:], "") + ".js") result.append( - SimpleTestCase(test, file_path, arch, mode, self.context, self, self.additional_flags)) + SimpleTestCase(tst, file_path, arch, mode, self.context, self, self.additional_flags)) return result class AbortTestConfiguration(SimpleTestConfiguration): @@ -169,6 +163,6 @@ class AbortTestConfiguration(SimpleTestConfiguration): def ListTests(self, current_path, path, arch, mode): result = super(AbortTestConfiguration, self).ListTests( current_path, path, arch, mode) - for test in result: - test.disable_core_files = True + for tst in result: + tst.disable_core_files = True return result |