1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
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
31
31
from bzrlib.errors import BzrBadParameterNotUnicode, InvalidURL
32
from bzrlib.osutils import (
34
is_inside_or_parent_of_any,
32
37
from bzrlib.tests import (
105
110
self.assertFalse(is_inside('foo.c', ''))
106
111
self.assertTrue(is_inside('', 'foo.c'))
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),
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))
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'),
131
self.assert_(is_inside_or_parent_of_any(dirs, fn))
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))
108
138
def test_rmtree(self):
109
139
# Check to remove tree with read-only files/dirs