~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_source.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
416
416
            error_msg.extend(('', ''))
417
417
        if error_msg:
418
418
            self.fail('\n'.join(error_msg))
 
419
 
 
420
    def test_feature_absolute_import(self):
 
421
        """Using absolute imports means avoiding unnecesary stat and
 
422
        open calls.
 
423
 
 
424
        Make sure that all non-test files have absolute imports enabled.
 
425
        """
 
426
        missing_absolute_import = []
 
427
        for fname, text in self.get_source_file_contents(
 
428
                extensions=('.py', )):
 
429
            if "/tests/" in fname or "test_" in fname:
 
430
                # We don't really care about tests
 
431
                continue
 
432
            if not "from __future__ import absolute_import" in text:
 
433
                missing_absolute_import.append(fname)
 
434
 
 
435
        if missing_absolute_import:
 
436
            self.fail(
 
437
                'The following files do not have absolute_import enabled:\n'
 
438
                '\n' + '\n'.join(missing_absolute_import))