/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-16 14:54:49 UTC
  • mto: This revision was merged to the branch mainline in revision 7174.
  • Revision ID: jelmer@jelmer.uk-20181116145449-5o6qlpcyd47lg1nj
Add test_flake8.

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
    )
323
324
        if problems:
324
325
            self.fail('\n\n'.join(problems))
325
326
 
 
327
    def test_flake8(self):
 
328
        # Disable lazy_regex, since flake8 uses sre_compile which can't handle
 
329
        # lazy_regex compile objects.
 
330
        from .. import lazy_regex
 
331
        lazy_regex.reset_compile()
 
332
        try:
 
333
            self.requireFeature(features.flake8)
 
334
            # Older versions of flake8 don't support the 'paths'
 
335
            # variable
 
336
            new_path = list(sys.path)
 
337
            new_path.insert(
 
338
                0, os.path.join(os.path.dirname(__file__), '..', '..', 'tools'))
 
339
            self.overrideAttr(sys, 'path', new_path)
 
340
            from flake8.api import legacy as flake8
 
341
            style_guide = flake8.get_style_guide(config=u'setup.cfg', jobs="1")
 
342
            report = style_guide.check_files(list(self.get_source_files()))
 
343
            self.assertEqual([], report.get_statistics(''))
 
344
        finally:
 
345
            lazy_regex.install_lazy_compile()
 
346
 
326
347
    def test_no_asserts(self):
327
348
        """bzr shouldn't use the 'assert' statement."""
328
349
        # assert causes too much variation between -O and not, and tends to