/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 bzrlib/tests/branch_implementations/test_parent.py

merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
import sys
19
19
 
20
20
import bzrlib.errors
21
21
from bzrlib.osutils import getcwd
22
 
from bzrlib.tests import TestCaseWithTransport
 
22
from bzrlib.tests import (
 
23
    TestCaseWithTransport,
 
24
    TestNotApplicable,
 
25
    TestSkipped,
 
26
    )
23
27
from bzrlib import urlutils
24
28
 
25
29
 
32
36
        """Branches should have no parent by default"""
33
37
        b = self.make_branch('.')
34
38
        self.assertEqual(None, b.get_parent())
35
 
        
 
39
 
36
40
    def test_set_get_parent(self):
37
41
        """Set, re-get and reset the parent"""
38
42
        b = self.make_branch('subdir')
67
71
            #       paths as well? Nobody has complained about it.
68
72
            pass
69
73
        else:
 
74
            b.lock_write()
70
75
            b._set_parent_location('/local/abs/path')
 
76
            b.unlock()
71
77
            self.assertEqual('file:///local/abs/path', b.get_parent())
72
78
 
73
79
    def test_get_invalid_parent(self):
79
85
        # Force the relative path to be something invalid
80
86
        # This should attempt to go outside the filesystem
81
87
        path = ('../'*(n_dirs+5)) + 'foo'
 
88
        b.lock_write()
82
89
        b._set_parent_location(path)
 
90
        b.unlock()
83
91
 
84
92
        # With an invalid branch parent, just return None
85
93
        self.assertRaises(bzrlib.errors.InaccessibleParent, b.get_parent)
86
94
 
 
95
    def test_win32_set_parent_on_another_drive(self):
 
96
        if sys.platform != 'win32':
 
97
            raise TestSkipped('windows-specific test')
 
98
        b = self.make_branch('.')
 
99
        base_url = b.abspath('.')
 
100
        if not base_url.startswith('file:///'):
 
101
            raise TestNotApplicable('this test should be run with local base')
 
102
        base = urlutils.local_path_from_url(base_url)
 
103
        other = 'file:///B:/path'
 
104
        if base[0] != 'C':
 
105
            other = 'file:///C:/path'
 
106
        b.set_parent(other)
 
107
        self.assertEquals(other, b._get_parent_location())