/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

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
335
336
        from flake8.main.application import Application
336
337
        from flake8.formatting.base import BaseFormatter
337
338
        app = Application()
352
353
            def handle(self, error):
353
354
                self.errors.append(error)
354
355
 
 
356
        try:
 
357
            app.initialize([])
 
358
        except argparse.ArgumentError as e:
 
359
            self.skipTest('broken flake8: %r' % e)
355
360
        app.formatter = Formatter()
356
 
        app.initialize([])
357
361
        app.run_checks()
358
362
        app.report()
359
363
        self.assertEqual(app.formatter.errors, [])
444
448
            error_msg.extend(('', ''))
445
449
        if error_msg:
446
450
            self.fail('\n'.join(error_msg))
447
 
 
448
 
    def test_feature_absolute_import(self):
449
 
        """Using absolute imports means avoiding unnecesary stat and
450
 
        open calls.
451
 
 
452
 
        Make sure that all non-test files have absolute imports enabled.
453
 
        """
454
 
        missing_absolute_import = []
455
 
        for fname, text in self.get_source_file_contents(
456
 
                extensions=('.py', '.pyx')):
457
 
            if "/tests/" in fname or "test_" in fname:
458
 
                # We don't really care about tests
459
 
                continue
460
 
            if "from __future__ import absolute_import" not in text:
461
 
                missing_absolute_import.append(fname)
462
 
 
463
 
        if missing_absolute_import:
464
 
            self.fail(
465
 
                'The following files do not have absolute_import enabled:\n'
466
 
                '\n' + '\n'.join(missing_absolute_import))