bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
1 |
# Copyright (C) 2007 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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
16 |
|
17 |
"""Test that all Tree's implement get_symlink_target"""
|
|
18 |
||
19 |
import os |
|
20 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy import ( |
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
22 |
osutils, |
23 |
tests, |
|
24 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
25 |
from breezy.tests import per_tree |
26 |
from breezy.tests import ( |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
27 |
features, |
28 |
)
|
|
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
29 |
|
30 |
||
31 |
class TestGetSymlinkTarget(per_tree.TestCaseWithTree): |
|
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
32 |
|
33 |
def get_tree_with_symlinks(self): |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
34 |
self.requireFeature(features.SymlinkFeature) |
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
35 |
tree = self.make_branch_and_tree('tree') |
36 |
os.symlink('foo', 'tree/link') |
|
37 |
os.symlink('../bar', 'tree/rel_link') |
|
38 |
os.symlink('/baz/bing', 'tree/abs_link') |
|
39 |
||
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
40 |
tree.add(['link', 'rel_link', 'abs_link']) |
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
41 |
return self._convert_tree(tree) |
42 |
||
43 |
def test_get_symlink_target(self): |
|
44 |
tree = self.get_tree_with_symlinks() |
|
45 |
tree.lock_read() |
|
46 |
self.addCleanup(tree.unlock) |
|
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
47 |
self.assertEqual('foo', tree.get_symlink_target('link')) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
48 |
self.assertEqual('../bar', |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
49 |
tree.get_symlink_target('rel_link')) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
50 |
self.assertEqual('/baz/bing', |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
51 |
tree.get_symlink_target('abs_link')) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
52 |
self.assertEqual('foo', |
|
6913.3.1
by Jelmer Vernooij
Avoid calls to path2id. |
53 |
tree.get_symlink_target('link')) |
|
3949.6.6
by Jelmer Vernooij
Skip unicode symlink tests on non-unicode file systems. |
54 |
|
55 |
def test_get_unicode_symlink_target(self): |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
56 |
self.requireFeature(features.SymlinkFeature) |
57 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
|
3949.6.6
by Jelmer Vernooij
Skip unicode symlink tests on non-unicode file systems. |
58 |
tree = self.make_branch_and_tree('tree') |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
59 |
target = u'targ\N{Euro Sign}t' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
60 |
os.symlink(target, u'tree/\u03b2_link'.encode(osutils._fs_enc)) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
61 |
tree.add([u'\u03b2_link']) |
|
3949.6.6
by Jelmer Vernooij
Skip unicode symlink tests on non-unicode file systems. |
62 |
tree.lock_read() |
63 |
self.addCleanup(tree.unlock) |
|
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
64 |
actual = tree.get_symlink_target(u'\u03b2_link') |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
65 |
self.assertEqual(target, actual) |