~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_whitebox.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-27 01:54:40 UTC
  • mto: (1711.2.26 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1734.
  • Revision ID: john@arbash-meinel.com-20060527015440-1a10495d8e56ed5f
deprecating appendpath, it does exactly what pathjoin does

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
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
16
 
 
17
1
import os
18
2
import unittest
19
3
 
20
 
from bzrlib import (
21
 
    osutils,
22
 
    )
23
4
from bzrlib.tests import TestCaseWithTransport, TestCase
24
 
from bzrlib.branch import Branch
 
5
from bzrlib.branch import ScratchBranch, Branch
25
6
from bzrlib.errors import PathNotChild
26
7
from bzrlib.osutils import relpath, pathjoin, abspath, realpath
27
8
 
36
17
        if it is inside a branch and return the path relative to the base.
37
18
        """
38
19
        import tempfile
39
 
 
 
20
        from bzrlib.osutils import rmtree
 
21
        
40
22
        savedir = os.getcwdu()
41
 
        dtmp = osutils.mkdtemp()
 
23
        dtmp = tempfile.mkdtemp()
42
24
        # On Mac OSX, /tmp actually expands to /private/tmp
43
25
        dtmp = realpath(dtmp)
44
26
 
45
27
        def rp(p):
46
28
            return relpath(dtmp, p)
47
 
 
 
29
        
48
30
        try:
49
31
            # check paths inside dtmp while standing outside it
50
32
            self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')
83
65
 
84
66
        finally:
85
67
            os.chdir(savedir)
86
 
            osutils.rmtree(dtmp)
 
68
            rmtree(dtmp)