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

  • Committer: Robert Collins
  • Date: 2007-09-04 04:12:07 UTC
  • mfrom: (2794 +trunk)
  • mto: (2592.3.126 repository)
  • mto: This revision was merged to the branch mainline in revision 2795.
  • Revision ID: robertc@robertcollins.net-20070904041207-zb3l8hfco0sp6hu8
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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
29
29
    win32utils,
30
30
    )
31
31
from bzrlib.errors import BzrBadParameterNotUnicode, InvalidURL
 
32
from bzrlib.osutils import (
 
33
        is_inside_any,
 
34
        is_inside_or_parent_of_any,
 
35
        pathjoin,
 
36
        )
32
37
from bzrlib.tests import (
33
38
        StringIOWrapper,
34
 
        TestCase, 
35
 
        TestCaseInTempDir, 
 
39
        TestCase,
 
40
        TestCaseInTempDir,
36
41
        TestSkipped,
37
42
        )
38
43
 
105
110
        self.assertFalse(is_inside('foo.c', ''))
106
111
        self.assertTrue(is_inside('', 'foo.c'))
107
112
 
 
113
    def test_is_inside_any(self):
 
114
        SRC_FOO_C = pathjoin('src', 'foo.c')
 
115
        for dirs, fn in [(['src', 'doc'], SRC_FOO_C),
 
116
                         (['src'], SRC_FOO_C),
 
117
                         (['src'], 'src'),
 
118
                         ]:
 
119
            self.assert_(is_inside_any(dirs, fn))
 
120
        for dirs, fn in [(['src'], 'srccontrol'),
 
121
                         (['src'], 'srccontrol/foo')]:
 
122
            self.assertFalse(is_inside_any(dirs, fn))
 
123
 
 
124
    def test_is_inside_or_parent_of_any(self):
 
125
        for dirs, fn in [(['src', 'doc'], 'src/foo.c'),
 
126
                         (['src'], 'src/foo.c'),
 
127
                         (['src/bar.c'], 'src'),
 
128
                         (['src/bar.c', 'bla/foo.c'], 'src'),
 
129
                         (['src'], 'src'),
 
130
                         ]:
 
131
            self.assert_(is_inside_or_parent_of_any(dirs, fn))
 
132
            
 
133
        for dirs, fn in [(['src'], 'srccontrol'),
 
134
                         (['srccontrol/foo.c'], 'src'),
 
135
                         (['src'], 'srccontrol/foo')]:
 
136
            self.assertFalse(is_inside_or_parent_of_any(dirs, fn))
 
137
 
108
138
    def test_rmtree(self):
109
139
        # Check to remove tree with read-only files/dirs
110
140
        os.mkdir('dir')