19
19
For interface contract tests, see tests/bzr_dir_implementations.
22
23
from StringIO import StringIO
24
28
import bzrlib.branch
25
29
import bzrlib.bzrdir as bzrdir
26
30
import bzrlib.errors as errors
392
396
get_transport(self.get_readonly_url('g/p/q')))
393
397
self.assertEqual('g/p/q', relpath)
399
def test_open_containing_tree_or_branch(self):
400
def local_branch_path(branch):
401
return os.path.realpath(urlutils.local_path_from_url(branch.base))
403
self.make_branch_and_tree('topdir')
404
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
406
self.assertEqual(os.path.realpath('topdir'),
407
os.path.realpath(tree.basedir))
408
self.assertEqual(os.path.realpath('topdir'), local_branch_path(branch))
409
self.assertIs(tree.bzrdir, branch.bzrdir)
410
self.assertEqual('foo', relpath)
411
self.make_branch('topdir/foo')
412
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
414
self.assertIs(tree, None)
415
self.assertEqual(os.path.realpath('topdir/foo'),
416
local_branch_path(branch))
417
self.assertEqual('', relpath)
395
419
def test_open_from_transport(self):
396
420
# transport pointing at bzrdir should give a bzrdir with root transport
397
421
# set to the given transport