~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_whitebox.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-22 14:12:18 UTC
  • mfrom: (6155.3.1 jam)
  • Revision ID: pqm@pqm.ubuntu.com-20110922141218-86s4uu6nqvourw4f
(jameinel) Cleanup comments bzrlib/smart/__init__.py (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
18
 
import unittest
19
18
 
20
 
from bzrlib.tests import TestCaseWithTransport, TestCase
21
 
from bzrlib.branch import Branch
 
19
from bzrlib import (
 
20
    osutils,
 
21
    )
 
22
from bzrlib.tests import TestCaseWithTransport
22
23
from bzrlib.errors import PathNotChild
23
24
from bzrlib.osutils import relpath, pathjoin, abspath, realpath
24
25
 
27
28
 
28
29
    def test_relpath(self):
29
30
        """test for branch path lookups
30
 
    
 
31
 
31
32
        bzrlib.osutils._relpath do a simple but subtle
32
33
        job: given a path (either relative to cwd or absolute), work out
33
34
        if it is inside a branch and return the path relative to the base.
34
35
        """
35
36
        import tempfile
36
 
        from bzrlib.osutils import rmtree
37
 
        
 
37
 
38
38
        savedir = os.getcwdu()
39
 
        dtmp = tempfile.mkdtemp()
 
39
        dtmp = osutils.mkdtemp()
40
40
        # On Mac OSX, /tmp actually expands to /private/tmp
41
41
        dtmp = realpath(dtmp)
42
42
 
43
43
        def rp(p):
44
44
            return relpath(dtmp, p)
45
 
        
 
45
 
46
46
        try:
47
47
            # check paths inside dtmp while standing outside it
48
48
            self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')
81
81
 
82
82
        finally:
83
83
            os.chdir(savedir)
84
 
            rmtree(dtmp)
 
84
            osutils.rmtree(dtmp)