/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_source.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-17 00:47:52 UTC
  • mfrom: (7182 work)
  • mto: This revision was merged to the branch mainline in revision 7305.
  • Revision ID: jelmer@jelmer.uk-20181117004752-6ywampe5pfywlby4
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    )
32
32
import breezy.branch
33
33
from breezy.tests import (
 
34
    features,
34
35
    TestCase,
35
36
    TestSkipped,
36
37
    )
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)
93
94
 
94
95
    def test_branch_WorkingTree(self):
205
206
            else:
206
207
                if 'by Canonical' in match.group():
207
208
                    incorrect.append((fname,
208
 
                        'should not have: "by Canonical": %s'
209
 
                        % (match.group(),)))
 
209
                                      'should not have: "by Canonical": %s'
 
210
                                      % (match.group(),)))
210
211
 
211
212
        if incorrect:
212
213
            help_text = ["Some files have missing or incorrect copyright"
219
220
                         "or add '# Copyright (C)"
220
221
                         " 2007 Bazaar hackers' to these files:",
221
222
                         "",
222
 
                        ]
 
223
                         ]
223
224
            for fname, comment in incorrect:
224
225
                help_text.append(fname)
225
226
                help_text.append((' ' * 4) + comment)
275
276
 
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))
280
281
 
281
282
    def test_coding_style(self):
309
310
        problems = []
310
311
        if tabs:
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:"
321
 
               '\n\n    %s'
322
 
               % ('\n    '.join(no_newline_at_eof)))
 
321
                            "newline at the end:"
 
322
                            '\n\n    %s'
 
323
                            % ('\n    '.join(no_newline_at_eof)))
323
324
        if problems:
324
325
            self.fail('\n\n'.join(problems))
325
326
 
 
327
    def test_flake8(self):
 
328
        self.requireFeature(features.flake8)
 
329
        # Older versions of flake8 don't support the 'paths'
 
330
        # variable
 
331
        new_path = list(sys.path)
 
332
        new_path.insert(
 
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(''))
 
339
 
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
424
438
                continue
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)
427
441
 
428
442
        if missing_absolute_import: