~bzr-pqm/bzr/bzr.dev

1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
1
# Copyright (C) 2006 Canonical Ltd
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
17
18
import os
19
20
from bzrlib.osutils import basename
21
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
22
23
24
class TestIsControlFilename(TestCaseWithWorkingTree):
25
26
    def validate_tree_is_controlfilename(self, tree):
27
        """check that 'tree' obeys the contract for is_control_filename."""
28
        bzrdirname = basename(tree.bzrdir.transport.base[:-1])
29
        self.assertTrue(tree.is_control_filename(bzrdirname))
30
        self.assertTrue(tree.is_control_filename(bzrdirname + '/subdir'))
31
        self.assertFalse(tree.is_control_filename('dir/' + bzrdirname))
32
        self.assertFalse(tree.is_control_filename('dir/' + bzrdirname + '/sub'))
33
34
    def test_dotbzr_is_control_in_cwd(self):
35
        tree = self.make_branch_and_tree('.')
36
        self.validate_tree_is_controlfilename(tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
37
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
38
    def test_dotbzr_is_control_in_subdir(self):
39
        tree = self.make_branch_and_tree('subdir')
40
        self.validate_tree_is_controlfilename(tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
41