~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_branch.py

  • Committer: abentley
  • Date: 2006-04-20 23:47:53 UTC
  • mfrom: (1681 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: abentley@lappy-20060420234753-6a6874b76f09f86d
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import bzrlib.gpg
34
34
from bzrlib.osutils import getcwd
35
35
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
 
36
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
36
37
from bzrlib.trace import mutter
37
38
import bzrlib.transactions as transactions
38
39
from bzrlib.transport import get_transport
47
48
# hooking into the Transport.
48
49
 
49
50
 
50
 
class TestCaseWithBranch(TestCaseWithTransport):
 
51
class TestCaseWithBranch(TestCaseWithBzrDir):
51
52
 
52
53
    def setUp(self):
53
54
        super(TestCaseWithBranch, self).setUp()
55
56
 
56
57
    def get_branch(self):
57
58
        if self.branch is None:
58
 
            self.branch = self.make_branch(None)
 
59
            self.branch = self.make_branch('')
59
60
        return self.branch
60
61
 
61
 
    def make_branch(self, relpath):
62
 
        repo = self.make_repository(relpath)
 
62
    def make_branch(self, relpath, format=None):
 
63
        repo = self.make_repository(relpath, format=format)
63
64
        # fixme RBC 20060210 this isnt necessarily a fixable thing,
64
65
        # Skipped is the wrong exception to raise.
65
66
        try:
67
68
        except errors.UninitializableFormat:
68
69
            raise TestSkipped('Uninitializable branch format')
69
70
 
70
 
    def make_repository(self, relpath, shared=False):
71
 
        try:
72
 
            url = self.get_url(relpath)
73
 
            segments = url.split('/')
74
 
            if segments and segments[-1] not in ('', '.'):
75
 
                parent = '/'.join(segments[:-1])
76
 
                t = get_transport(parent)
77
 
                try:
78
 
                    t.mkdir(segments[-1])
79
 
                except FileExists:
80
 
                    pass
81
 
            made_control = self.bzrdir_format.initialize(url)
82
 
            return made_control.create_repository(shared=shared)
83
 
        except UninitializableFormat:
84
 
            raise TestSkipped("Format %s is not initializable.")
 
71
    def make_repository(self, relpath, shared=False, format=None):
 
72
        made_control = self.make_bzrdir(relpath, format=format)
 
73
        return made_control.create_repository(shared=shared)
85
74
 
86
75
 
87
76
class TestBranch(TestCaseWithBranch):
322
311
        self.assertEqual(repo.bzrdir.root_transport.base,
323
312
                         child_branch.repository.bzrdir.root_transport.base)
324
313
 
 
314
    def test_format_description(self):
 
315
        tree = self.make_branch_and_tree('tree')
 
316
        text = tree.branch._format.get_format_description()
 
317
        self.failUnless(len(text))
 
318
 
325
319
 
326
320
class ChrootedTests(TestCaseWithBranch):
327
321
    """A support class that provides readonly urls outside the local namespace.