~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_source.py

  • Committer: Martin Packman
  • Date: 2012-01-05 10:44:12 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6427.
  • Revision ID: martin.packman@canonical.com-20120105104412-z03fi9m43h946fvs
Merge bzr.dev to resolve conflicts

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))