tools: python: ignore instead of select flake8 rules · nodejs/node@1fc4255 (original) (raw)
`@@ -27,18 +27,12 @@
`
27
27
``
28
28
`import test
`
29
29
`import os
`
30
``
`-
from os.path import join, dirname, exists, splitext
`
31
30
`import re
`
32
``
`-
import ast
`
33
``
-
34
``
`-
try:
`
35
``
`-
reduce
`
36
``
`-
except NameError:
`
37
``
`-
from functools import reduce
`
``
31
`+
from functools import reduce
`
38
32
``
39
33
``
40
34
`FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
`
41
``
-
``
35
`+
LS_RE = re.compile(r'^test-.*.m?js$')
`
42
36
``
43
37
`class SimpleTestCase(test.TestCase):
`
44
38
``
`@@ -107,15 +101,15 @@ def init(self, context, root, section, additional=None):
`
107
101
`self.additional_flags = []
`
108
102
``
109
103
`def Ls(self, path):
`
110
``
`-
return [f for f in os.listdir(path) if re.match('^test-.*.m?js$', f)]
`
``
104
`+
return [f for f in os.listdir(path) if LS_RE.match(f)]
`
111
105
``
112
106
`def ListTests(self, current_path, path, arch, mode):
`
113
``
`-
all_tests = [current_path + [t] for t in self.Ls(join(self.root))]
`
``
107
`+
all_tests = [current_path + [t] for t in self.Ls(os.path.join(self.root))]
`
114
108
`result = []
`
115
``
`-
for test in all_tests:
`
116
``
`-
if self.Contains(path, test):
`
117
``
`-
file_path = join(self.root, reduce(join, test[1:], ""))
`
118
``
`-
test_name = test[:-1] + [splitext(test[-1])[0]]
`
``
109
`+
for tst in all_tests:
`
``
110
`+
if self.Contains(path, tst):
`
``
111
`+
file_path = os.path.join(self.root, reduce(os.path.join, tst[1:], ""))
`
``
112
`+
test_name = tst[:-1] + [os.path.splitext(tst[-1])[0]]
`
119
113
`result.append(SimpleTestCase(test_name, file_path, arch, mode,
`
120
114
`self.context, self, self.additional_flags))
`
121
115
`return result
`
`@@ -131,8 +125,8 @@ def init(self, context, root, section, additional=None):
`
131
125
`def ListTests(self, current_path, path, arch, mode):
`
132
126
`result = super(ParallelTestConfiguration, self).ListTests(
`
133
127
`current_path, path, arch, mode)
`
134
``
`-
for test in result:
`
135
``
`-
test.parallel = True
`
``
128
`+
for tst in result:
`
``
129
`+
tst.parallel = True
`
136
130
`return result
`
137
131
``
138
132
`class AddonTestConfiguration(SimpleTestConfiguration):
`
`@@ -145,20 +139,20 @@ def SelectTest(name):
`
145
139
``
146
140
`result = []
`
147
141
`for subpath in os.listdir(path):
`
148
``
`-
if os.path.isdir(join(path, subpath)):
`
149
``
`-
for f in os.listdir(join(path, subpath)):
`
``
142
`+
if os.path.isdir(os.path.join(path, subpath)):
`
``
143
`+
for f in os.listdir(os.path.join(path, subpath)):
`
150
144
`if SelectTest(f):
`
151
145
`result.append([subpath, f[:-3]])
`
152
146
`return result
`
153
147
``
154
148
`def ListTests(self, current_path, path, arch, mode):
`
155
``
`-
all_tests = [current_path + t for t in self.Ls(join(self.root))]
`
``
149
`+
all_tests = [current_path + t for t in self.Ls(os.path.join(self.root))]
`
156
150
`result = []
`
157
``
`-
for test in all_tests:
`
158
``
`-
if self.Contains(path, test):
`
159
``
`-
file_path = join(self.root, reduce(join, test[1:], "") + ".js")
`
``
151
`+
for tst in all_tests:
`
``
152
`+
if self.Contains(path, tst):
`
``
153
`+
file_path = os.path.join(self.root, reduce(os.path.join, tst[1:], "") + ".js")
`
160
154
`result.append(
`
161
``
`-
SimpleTestCase(test, file_path, arch, mode, self.context, self, self.additional_flags))
`
``
155
`+
SimpleTestCase(tst, file_path, arch, mode, self.context, self, self.additional_flags))
`
162
156
`return result
`
163
157
``
164
158
`class AbortTestConfiguration(SimpleTestConfiguration):
`
`@@ -169,6 +163,6 @@ def init(self, context, root, section, additional=None):
`
169
163
`def ListTests(self, current_path, path, arch, mode):
`
170
164
`result = super(AbortTestConfiguration, self).ListTests(
`
171
165
`current_path, path, arch, mode)
`
172
``
`-
for test in result:
`
173
``
`-
test.disable_core_files = True
`
``
166
`+
for tst in result:
`
``
167
`+
tst.disable_core_files = True
`
174
168
`return result
`