~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_whitebox.py

  • Committer: Robert Collins
  • Date: 2006-01-02 22:37:32 UTC
  • mfrom: (1185.50.33 bzr-jam-integration)
  • Revision ID: robertc@robertcollins.net-20060102223732-d5221b37ff0f7888
Merge in John Meinels integration branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from bzrlib.tests import TestCaseInTempDir, TestCase
5
5
from bzrlib.branch import ScratchBranch, Branch
6
6
from bzrlib.errors import PathNotChild
 
7
from bzrlib.osutils import relpath, pathjoin, abspath, realpath
7
8
 
8
9
 
9
10
class TestBranch(TestCaseInTempDir):
76
77
        job: given a path (either relative to cwd or absolute), work out
77
78
        if it is inside a branch and return the path relative to the base.
78
79
        """
79
 
        from bzrlib.osutils import relpath
80
80
        import tempfile, shutil
81
81
        
82
82
        savedir = os.getcwdu()
83
83
        dtmp = tempfile.mkdtemp()
84
84
        # On Mac OSX, /tmp actually expands to /private/tmp
85
 
        dtmp = os.path.realpath(dtmp)
 
85
        dtmp = realpath(dtmp)
86
86
 
87
87
        def rp(p):
88
88
            return relpath(dtmp, p)
89
89
        
90
90
        try:
91
91
            # check paths inside dtmp while standing outside it
92
 
            self.assertEqual(rp(os.path.join(dtmp, 'foo')), 'foo')
 
92
            self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')
93
93
 
94
94
            # root = nothing
95
95
            self.assertEqual(rp(dtmp), '')
112
112
            # directory, or nearby
113
113
            os.chdir(dtmp)
114
114
 
115
 
            FOO_BAR_QUUX = os.path.join('foo', 'bar', 'quux')
116
 
            self.assertEqual(rp('foo/bar/quux'), FOO_BAR_QUUX)
 
115
            self.assertEqual(rp('foo/bar/quux'), 'foo/bar/quux')
117
116
 
118
117
            self.assertEqual(rp('foo'), 'foo')
119
118
 
120
119
            self.assertEqual(rp('./foo'), 'foo')
121
120
 
122
 
            self.assertEqual(rp(os.path.abspath('foo')), 'foo')
 
121
            self.assertEqual(rp(abspath('foo')), 'foo')
123
122
 
124
123
            self.assertRaises(PathNotChild,
125
124
                              rp, '../foo')