bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.77.9
by Ian Clatworthy
common_directory tests & tweaks |
1 |
# Copyright (C) 2009 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 |
"""Test the helper functions."""
|
|
18 |
||
19 |
from bzrlib import tests |
|
20 |
||
21 |
from bzrlib.plugins.fastimport import ( |
|
22 |
helpers, |
|
23 |
)
|
|
24 |
||
25 |
||
26 |
class TestCommonDirectory(tests.TestCase): |
|
27 |
||
28 |
def test_no_paths(self): |
|
29 |
c = helpers.common_directory(None) |
|
30 |
self.assertEqual(c, None) |
|
31 |
c = helpers.common_directory([]) |
|
32 |
self.assertEqual(c, None) |
|
33 |
||
34 |
def test_one_path(self): |
|
35 |
c = helpers.common_directory(['foo']) |
|
36 |
self.assertEqual(c, '') |
|
37 |
c = helpers.common_directory(['foo/']) |
|
38 |
self.assertEqual(c, 'foo/') |
|
39 |
c = helpers.common_directory(['foo/bar']) |
|
40 |
self.assertEqual(c, 'foo/') |
|
41 |
||
42 |
def test_two_paths(self): |
|
43 |
c = helpers.common_directory(['foo', 'bar']) |
|
44 |
self.assertEqual(c, '') |
|
45 |
c = helpers.common_directory(['foo/', 'bar']) |
|
46 |
self.assertEqual(c, '') |
|
47 |
c = helpers.common_directory(['foo/', 'foo/bar']) |
|
48 |
self.assertEqual(c, 'foo/') |
|
49 |
c = helpers.common_directory(['foo/bar/x', 'foo/bar/y']) |
|
50 |
self.assertEqual(c, 'foo/bar/') |
|
51 |
c = helpers.common_directory(['foo/bar/aa_x', 'foo/bar/aa_y']) |
|
52 |
self.assertEqual(c, 'foo/bar/') |
|
53 |
||
54 |
def test_lots_of_paths(self): |
|
55 |
c = helpers.common_directory(['foo/bar/x', 'foo/bar/y', 'foo/bar/z']) |
|
56 |
self.assertEqual(c, 'foo/bar/') |