/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: 2019-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
        new_path.insert(
333
333
            0, os.path.join(os.path.dirname(__file__), '..', '..', 'tools'))
334
334
        self.overrideAttr(sys, 'path', new_path)
335
 
        import argparse
336
 
        from flake8.main.application import Application
337
 
        from flake8.formatting.base import BaseFormatter
338
 
        app = Application()
339
 
        app.config = u'setup.cfg'
340
 
        app.jobs = 1
341
 
 
342
 
        class Formatter(BaseFormatter):
343
 
 
344
 
            def __init__(self):
345
 
                self.errors = []
346
 
 
347
 
            def start(self):
348
 
                pass
349
 
 
350
 
            def stop(self):
351
 
                app.file_checker_manager.report()
352
 
 
353
 
            def handle(self, error):
354
 
                self.errors.append(error)
355
 
 
356
 
        try:
357
 
            app.initialize([])
358
 
        except argparse.ArgumentError as e:
359
 
            self.skipTest('broken flake8: %r' % e)
360
 
        app.formatter = Formatter()
361
 
        app.run_checks()
362
 
        app.report()
363
 
        self.assertEqual(app.formatter.errors, [])
 
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(''))
364
339
 
365
340
    def test_no_asserts(self):
366
341
        """bzr shouldn't use the 'assert' statement."""
448
423
            error_msg.extend(('', ''))
449
424
        if error_msg:
450
425
            self.fail('\n'.join(error_msg))
 
426
 
 
427
    def test_feature_absolute_import(self):
 
428
        """Using absolute imports means avoiding unnecesary stat and
 
429
        open calls.
 
430
 
 
431
        Make sure that all non-test files have absolute imports enabled.
 
432
        """
 
433
        missing_absolute_import = []
 
434
        for fname, text in self.get_source_file_contents(
 
435
                extensions=('.py', '.pyx')):
 
436
            if "/tests/" in fname or "test_" in fname:
 
437
                # We don't really care about tests
 
438
                continue
 
439
            if "from __future__ import absolute_import" not in text:
 
440
                missing_absolute_import.append(fname)
 
441
 
 
442
        if missing_absolute_import:
 
443
            self.fail(
 
444
                'The following files do not have absolute_import enabled:\n'
 
445
                '\n' + '\n'.join(missing_absolute_import))