88
89
# increase it, then you almost certainly are doing something wrong as
89
90
# the relationship from working_tree to branch is one way.
90
91
# Note that this is an exact equality so that when the number drops,
91
#it is not given a buffer but rather has this test updated immediately.
92
# it is not given a buffer but rather has this test updated immediately.
92
93
self.assertEqual(0, occurences)
94
95
def test_branch_WorkingTree(self):
219
220
"or add '# Copyright (C)"
220
221
" 2007 Bazaar hackers' to these files:",
223
224
for fname, comment in incorrect:
224
225
help_text.append(fname)
225
226
help_text.append((' ' * 4) + comment)
276
277
def _format_message(self, dict_, message):
277
278
files = sorted(["%s: %s" % (f, ', '.join([str(i + 1) for i in lines]))
278
for f, lines in dict_.items()])
279
for f, lines in dict_.items()])
279
280
return message + '\n\n %s' % ('\n '.join(files))
281
282
def test_coding_style(self):
311
312
problems.append(self._format_message(tabs,
312
'Tab characters were found in the following source files.'
313
'\nThey should either be replaced by "\\t" or by spaces:'))
313
'Tab characters were found in the following source files.'
314
'\nThey should either be replaced by "\\t" or by spaces:'))
314
315
if illegal_newlines:
315
316
problems.append(self._format_message(illegal_newlines,
316
'Non-unix newlines were found in the following source files:'))
317
'Non-unix newlines were found in the following source files:'))
317
318
if no_newline_at_eof:
318
319
no_newline_at_eof.sort()
319
320
problems.append("The following source files doesn't have a "
320
"newline at the end:"
322
% ('\n '.join(no_newline_at_eof)))
321
"newline at the end:"
323
% ('\n '.join(no_newline_at_eof)))
324
325
self.fail('\n\n'.join(problems))
327
def test_flake8(self):
328
self.requireFeature(features.flake8)
329
# Older versions of flake8 don't support the 'paths'
331
new_path = list(sys.path)
333
0, os.path.join(os.path.dirname(__file__), '..', '..', 'tools'))
334
self.overrideAttr(sys, 'path', new_path)
335
from flake8.api import legacy as flake8
336
style_guide = flake8.get_style_guide(config=u'setup.cfg', jobs="1")
337
report = style_guide.check_files(list(self.get_source_files()))
338
self.assertEqual([], report.get_statistics(''))
326
340
def test_no_asserts(self):
327
341
"""bzr shouldn't use the 'assert' statement."""
328
342
# assert causes too much variation between -O and not, and tends to
422
436
if "/tests/" in fname or "test_" in fname:
423
437
# We don't really care about tests
425
if not "from __future__ import absolute_import" in text:
439
if "from __future__ import absolute_import" not in text:
426
440
missing_absolute_import.append(fname)
428
442
if missing_absolute_import: