~bzr-pqm/bzr/bzr.dev

« 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:
18
18
import os
19
19
 
20
20
from bzrlib.branch import Branch
21
 
from bzrlib.osutils import abspath, realpath
 
21
import bzrlib.errors
 
22
from bzrlib.osutils import abspath, realpath, getcwd
 
23
from bzrlib.urlutils import local_path_from_url, local_path_to_url, escape
22
24
from bzrlib.tests import TestCaseWithTransport
23
25
 
24
26
 
38
40
        url = 'http://bazaar-vcs.org/bzr/bzr.dev'
39
41
        b.set_parent(url)
40
42
        self.assertEquals(b.get_parent(), url)
 
43
        self.assertEqual(b.control_files.get('parent').read().strip('\n'), url)
 
44
 
41
45
        b.set_parent(None)
42
46
        self.assertEquals(b.get_parent(), None)
 
47
 
 
48
        b.set_parent('../other_branch')
 
49
        cwd = getcwd()
 
50
 
 
51
        self.assertEquals(b.get_parent(), local_path_to_url('../other_branch'))
 
52
        path = local_path_to_url('../yanb')
 
53
        b.set_parent(path)
 
54
        self.assertEqual(b.control_files.get('parent').read().strip('\n'), 
 
55
            '../yanb')
 
56
        self.assertEqual(b.get_parent(), path)
 
57
 
 
58
 
 
59
        self.assertRaises(bzrlib.errors.InvalidURL, b.set_parent, u'\xb5')
 
60
        b.set_parent(escape(u'\xb5'))
 
61
        self.assertEqual(b.control_files.get('parent').read().strip('\n'), 
 
62
            '%C2%B5')
 
63
 
 
64
        self.assertEqual(b.get_parent(), b.base + '%C2%B5')
 
65