Skip to content

Commit 6ffa51a

Browse files
committed
Improve the test framework to count the errors, motivated by issue #237
1 parent 4afc7ae commit 6ffa51a

9 files changed

Lines changed: 41 additions & 34 deletions

File tree

testsuite/E12.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
'key1': 'value',
5353
'key2': 'value',
5454
}
55-
#: E121
55+
#: E121 E121
5656
rv.update(dict.fromkeys((
5757
'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
5858
'reasonComment_de', 'reasonComment_it'),
5959
'?'),
6060
"foo")
61-
#: E121
61+
#: E121 E121
6262
abricot = 3 + \
6363
4 + \
6464
5 + 6
@@ -121,7 +121,7 @@
121121
"bad", "hanging", "close"
122122
)
123123
#
124-
#: E123
124+
#: E123 E123 E123
125125
result = {
126126
'foo': [
127127
'bar', {
@@ -166,7 +166,7 @@
166166
help="exclude files or directories which match these "
167167
"comma separated patterns (default: %s)" % DEFAULT_EXCLUDE
168168
)
169-
#: E124 E128
169+
#: E124 E128 E128
170170
if line_removed:
171171
self.event(cr, uid,
172172
name="Removing the option for contract",
@@ -208,14 +208,14 @@ def qualify_by_address(
208208
1, 2, 3,
209209
4, 5, 6,
210210
]
211-
#: E126
211+
#: E126 E126
212212
abris = 3 + \
213213
4 + \
214214
5 + 6
215215
#: E126
216216
fixed = re.sub(r'\t+', ' ', target[c::-1], 1)[::-1] + \
217217
target[c + 1:]
218-
#: E126
218+
#: E126 E126
219219
rv.update(dict.fromkeys((
220220
'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
221221
'reasonComment_de', 'reasonComment_it'),
@@ -313,13 +313,13 @@ def qualify_by_address(self, cr, uid, ids, context=None,
313313
#: E127
314314
foo(1, 2, 3,
315315
4, 5, 6)
316-
#: E128
316+
#: E128 E128
317317
if line_removed:
318318
self.event(cr, uid,
319319
name="Removing the option for contract",
320320
description="contract line has been removed",
321321
)
322-
#: E124 E127
322+
#: E124 E127 E127
323323
if line_removed:
324324
self.event(cr, uid,
325325
name="Removing the option for contract",

testsuite/E21.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#: E211
22
spam (1)
3-
#: E211
3+
#: E211 E211
44
dict ['key'] = list [index]
55
#: E211
66
dict['key'] ['subkey'] = list[index]

testsuite/E22.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#: E221
22
a = 12 + 3
33
b = 4 + 5
4-
#: E221
4+
#: E221 E221
55
x = 1
66
y = 2
77
long_variable = 3
8-
#: E221
8+
#: E221 E221
99
x[0] = 1
1010
x[1] = 2
1111
long_variable = 3
12-
#: E221
12+
#: E221 E221
1313
x = f(x) + 1
1414
y = long_variable + 2
1515
z = x[0] + 3
@@ -23,11 +23,11 @@
2323
#: E222
2424
a = a + 1
2525
b = b + 10
26-
#: E222
26+
#: E222 E222
2727
x = -1
2828
y = -2
2929
long_variable = 3
30-
#: E222
30+
#: E222 E222
3131
x[0] = 1
3232
x[1] = 2
3333
long_variable = 3
@@ -68,9 +68,9 @@
6868
_1kB = _1MB >>10
6969
#: E225
7070
_1kB = _1MB>> 10
71-
#: E225
71+
#: E225 E225
7272
i=i+ 1
73-
#: E225
73+
#: E225 E225
7474
i=i +1
7575
#: E225 E226
7676
i=i+1
@@ -86,15 +86,15 @@
8686

8787
#: E226
8888
z = 2**30
89-
#: E226
89+
#: E226 E226
9090
c = (a+b) * (a-b)
9191
#: E226
9292
norman = True+False
9393
#: E226
9494
x = x*2 - 1
9595
#: E226
9696
x = x/2 - 1
97-
#: E226
97+
#: E226 E226
9898
hypot2 = x*x + y*y
9999
#: E226
100100
c = (a + b)*(a - b)

testsuite/E24.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
a = (1, 2) # tab before 2
77
#: Okay
88
b = (1, 20) # space before 20
9-
#: E241
9+
#: E241 E241 E241
1010
# issue 135
1111
more_spaces = [a, b,
1212
ef, +h,

testsuite/E25.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#: E251
1+
#: E251 E251
22
def foo(bar = False):
33
'''Test function with an error in declaration'''
44
pass
55
#: E251
66
foo(bar= True)
77
#: E251
88
foo(bar =True)
9-
#: E251
9+
#: E251 E251
1010
foo(bar = True)
1111
#: E251
1212
y = bar(root= "sdasd")

testsuite/E72.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
assert type(res) is not type((1, ))
3333
#: E211 E721
3434
assert type(res) == type ([2, ])
35-
#: E201 E202 E721
35+
#: E201 E201 E202 E721
3636
assert type(res) == type( ( ) )
3737
#: E201 E202 E721
3838
assert type(res) == type( (0, ) )

testsuite/E90.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
}
33
#: E901
44
= [x
5-
#: E901 E101 W191
5+
#: E901 E101 E101 W191 W191
66
while True:
77
try:
88
pass
99
except:
1010
print 'Whoops'
11-
#: E122 E225 E251 E701
11+
#: E122 E122 E225 E251 E251 E701
1212

1313
# Do not crash if code is invalid
1414
if msg:

testsuite/W19.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
pass
3939
#:
4040

41-
#: E101 W191
41+
#: E101 E101 W191 W191
4242
if start[1] > end_col and not (
4343
over_indent == 4 and indent_next):
4444
return(0, "E121 continuation line over-"
@@ -56,7 +56,7 @@ def long_function_name(
5656
if ((row < 0 or self.moduleCount <= row or
5757
col < 0 or self.moduleCount <= col)):
5858
raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
59-
#: E101 W191
59+
#: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191
6060
if bar:
6161
return(
6262
start, 'E121 lines starting with a '
@@ -86,14 +86,14 @@ def long_function_name(
8686
b == """abc def ghi
8787
jkl mno"""):
8888
return True
89-
#: E101 W191
89+
#: E101 W191 W191
9090
if length > options.max_line_length:
9191
return options.max_line_length, \
9292
"E501 line too long (%d characters)" % length
9393

9494

9595
#
96-
#: E101 W191
96+
#: E101 W191 W191
9797
if os.path.exists(os.path.join(path, PEP8_BIN)):
9898
cmd = ([os.path.join(path, PEP8_BIN)] +
9999
self._pep8_options(targetfile))

testsuite/support.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,28 @@ def __init__(self, options):
2828
def get_file_results(self):
2929
# Check if the expected errors were found
3030
label = '%s:%s:1' % (self.filename, self.line_offset)
31-
codes = sorted(self.expected)
32-
for code in codes:
31+
for code in self.expected:
3332
if not self.counters.get(code):
3433
self.file_errors += 1
3534
self.total_errors += 1
3635
print('%s: error %s not found' % (label, code))
36+
else:
37+
self.counters[code] -= 1
38+
for code, extra in sorted(self.counters.items()):
39+
if code not in self._benchmark_keys:
40+
if extra:
41+
self.file_errors += 1
42+
self.total_errors += 1
43+
print('%s: error %s found too many times (+%d)' %
44+
(label, code, extra))
45+
# Reset counters
46+
del self.counters[code]
3747
if self._verbose and not self.file_errors:
3848
print('%s: passed (%s)' %
39-
(label, ' '.join(codes) or 'Okay'))
49+
(label, ' '.join(self.expected) or 'Okay'))
4050
self.counters['test cases'] += 1
4151
if self.file_errors:
4252
self.counters['failed tests'] += 1
43-
# Reset counters
44-
for key in set(self.counters) - set(self._benchmark_keys):
45-
del self.counters[key]
4653
self.messages = {}
4754
return super(TestReport, self).get_file_results()
4855

0 commit comments

Comments
 (0)