/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/test_bzrdir.py

  • Committer: Aaron Bentley
  • Date: 2007-01-02 18:33:59 UTC
  • mto: (1551.9.35 Aaron's mergeable stuff)
  • mto: This revision was merged to the branch mainline in revision 2237.
  • Revision ID: abentley@panoramicfeedback.com-20070102183359-kco0xv9p9u13i70l
Add open_containing_tree_or_branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
For interface contract tests, see tests/bzr_dir_implementations.
20
20
"""
21
21
 
 
22
import os.path
22
23
from StringIO import StringIO
23
24
 
 
25
from bzrlib import (
 
26
    urlutils,
 
27
    )
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)
394
398
 
 
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))
 
402
 
 
403
        self.make_branch_and_tree('topdir')
 
404
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
 
405
            'topdir/foo')
 
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(
 
413
            'topdir/foo')
 
414
        self.assertIs(tree, None)
 
415
        self.assertEqual(os.path.realpath('topdir/foo'), 
 
416
                         local_branch_path(branch))
 
417
        self.assertEqual('', relpath)
 
418
 
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