/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: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""These tests are tests about the source code of bzrlib itself.
 
17
"""These tests are tests about the source code of breezy itself.
18
18
 
19
19
They are useful for testing code quality, checking coverage metric etc.
20
20
"""
26
26
import sys
27
27
import token
28
28
 
29
 
from bzrlib import (
 
29
from breezy import (
30
30
    osutils,
31
31
    )
32
 
import bzrlib.branch
33
 
from bzrlib.tests import (
 
32
import breezy.branch
 
33
from breezy.tests import (
34
34
    TestCase,
35
35
    TestSkipped,
36
36
    )
39
39
# Files which are listed here will be skipped when testing for Copyright (or
40
40
# GPL) statements.
41
41
COPYRIGHT_EXCEPTIONS = [
42
 
    'bzrlib/_bencode_py.py',
43
 
    'bzrlib/doc_generate/conf.py',
44
 
    'bzrlib/lsprof.py',
 
42
    'breezy/_bencode_py.py',
 
43
    'breezy/doc_generate/conf.py',
 
44
    'breezy/lsprof.py',
45
45
    ]
46
46
 
47
47
LICENSE_EXCEPTIONS = [
48
 
    'bzrlib/_bencode_py.py',
49
 
    'bzrlib/doc_generate/conf.py',
50
 
    'bzrlib/lsprof.py',
 
48
    'breezy/_bencode_py.py',
 
49
    'breezy/doc_generate/conf.py',
 
50
    'breezy/lsprof.py',
51
51
    ]
52
 
# Technically, 'bzrlib/lsprof.py' should be 'bzrlib/util/lsprof.py',
53
 
# (we do not check bzrlib/util/, since that is code bundled from elsewhere)
 
52
# Technically, 'breezy/lsprof.py' should be 'breezy/util/lsprof.py',
 
53
# (we do not check breezy/util/, since that is code bundled from elsewhere)
54
54
# but for compatibility with previous releases, we don't want to move it.
55
55
#
56
56
# sphinx_conf is semi-autogenerated.
83
83
    def test_branch_working_tree(self):
84
84
        """Test that the number of uses of working_tree in branch is stable."""
85
85
        occurences = self.find_occurences('self.working_tree()',
86
 
                                          self.source_file_name(bzrlib.branch))
 
86
                                          self.source_file_name(breezy.branch))
87
87
        # do not even think of increasing this number. If you think you need to
88
88
        # increase it, then you almost certainly are doing something wrong as
89
89
        # the relationship from working_tree to branch is one way.
94
94
    def test_branch_WorkingTree(self):
95
95
        """Test that the number of uses of working_tree in branch is stable."""
96
96
        occurences = self.find_occurences('WorkingTree',
97
 
                                          self.source_file_name(bzrlib.branch))
 
97
                                          self.source_file_name(breezy.branch))
98
98
        # Do not even think of increasing this number. If you think you need to
99
99
        # increase it, then you almost certainly are doing something wrong as
100
100
        # the relationship from working_tree to branch is one way.
104
104
 
105
105
class TestSource(TestSourceHelper):
106
106
 
107
 
    def get_bzrlib_dir(self):
108
 
        """Get the path to the root of bzrlib"""
109
 
        source = self.source_file_name(bzrlib)
 
107
    def get_breezy_dir(self):
 
108
        """Get the path to the root of breezy"""
 
109
        source = self.source_file_name(breezy)
110
110
        source_dir = os.path.dirname(source)
111
111
 
112
 
        # Avoid the case when bzrlib is packaged in a zip file
 
112
        # Avoid the case when breezy is packaged in a zip file
113
113
        if not os.path.isdir(source_dir):
114
114
            raise TestSkipped(
115
 
                'Cannot find bzrlib source directory. Expected %s'
 
115
                'Cannot find breezy source directory. Expected %s'
116
116
                % source_dir)
117
117
        return source_dir
118
118
 
119
119
    def get_source_files(self, extensions=None):
120
 
        """Yield all source files for bzr and bzrlib
 
120
        """Yield all source files for bzr and breezy
121
121
 
122
122
        :param our_files_only: If true, exclude files from included libraries
123
123
            or plugins.
124
124
        """
125
 
        bzrlib_dir = self.get_bzrlib_dir()
 
125
        breezy_dir = self.get_breezy_dir()
126
126
        if extensions is None:
127
127
            extensions = ('.py',)
128
128
 
129
129
        # This is the front-end 'bzr' script
130
 
        bzr_path = self.get_bzr_path()
 
130
        bzr_path = self.get_brz_path()
131
131
        yield bzr_path
132
132
 
133
 
        for root, dirs, files in os.walk(bzrlib_dir):
 
133
        for root, dirs, files in os.walk(breezy_dir):
134
134
            for d in dirs:
135
135
                if d.endswith('.tmp'):
136
136
                    dirs.remove(d)
153
153
            yield fname, text
154
154
 
155
155
    def is_our_code(self, fname):
156
 
        """True if it's a "real" part of bzrlib rather than external code"""
 
156
        """True if it's a "real" part of breezy rather than external code"""
157
157
        if '/util/' in fname or '/plugins/' in fname:
158
158
            return False
159
159
        else:
220
220
                         "",
221
221
                         "Please either add them to the list of"
222
222
                         " COPYRIGHT_EXCEPTIONS in"
223
 
                         " bzrlib/tests/test_source.py",
 
223
                         " breezy/tests/test_source.py",
224
224
                         # this is broken to prevent a false match
225
225
                         "or add '# Copyright (C)"
226
226
                         " 2007 Canonical Ltd' to these files:",
265
265
                         "",
266
266
                         "Please either add them to the list of"
267
267
                         " LICENSE_EXCEPTIONS in"
268
 
                         " bzrlib/tests/test_source.py",
 
268
                         " breezy/tests/test_source.py",
269
269
                         "Or add the following text to the beginning:",
270
270
                         gpl_txt]
271
271
            for fname in incorrect: