~bzr/ubuntu/maverick/bzr/bzr-ppa

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_source.py

  • Committer: Max Bowsher
  • Date: 2012-03-11 00:18:38 UTC
  • mfrom: (144.1.23 natty)
  • Revision ID: _@maxb.eu-20120311001838-orc0v5vksuqp0431
Tags: 2.5.0-2~bazaar1~maverick1
MergeĀ 2.5

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