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 |
||
21 |
from bzrlib import ( |
|
22 |
errors, |
|
23 |
osutils, |
|
24 |
tests, |
|
25 |
)
|
|
26 |
from bzrlib.tests.tree_implementations import TestCaseWithTree |
|
27 |
||
28 |
||
29 |
class TestGetSymlinkTarget(TestCaseWithTree): |
|
30 |
||
31 |
def get_tree_with_symlinks(self): |
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
32 |
self.requireFeature(tests.SymlinkFeature) |
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
33 |
tree = self.make_branch_and_tree('tree') |
34 |
os.symlink('foo', 'tree/link') |
|
35 |
os.symlink('../bar', 'tree/rel_link') |
|
36 |
os.symlink('/baz/bing', 'tree/abs_link') |
|
37 |
||
3949.6.6
by Jelmer Vernooij
Skip unicode symlink tests on non-unicode file systems. |
38 |
tree.add(['link', 'rel_link', 'abs_link'], |
39 |
['link-id', 'rel-link-id', 'abs-link-id']) |
|
2255.2.134
by John Arbash Meinel
Add a tree-test for get_symlink_target |
40 |
return self._convert_tree(tree) |
41 |
||
42 |
def test_get_symlink_target(self): |
|
43 |
tree = self.get_tree_with_symlinks() |
|
44 |
tree.lock_read() |
|
45 |
self.addCleanup(tree.unlock) |
|
46 |
self.assertEqual('foo', tree.get_symlink_target('link-id')) |
|
47 |
self.assertEqual('../bar', tree.get_symlink_target('rel-link-id')) |
|
48 |
self.assertEqual('/baz/bing', tree.get_symlink_target('abs-link-id')) |
|
3949.6.6
by Jelmer Vernooij
Skip unicode symlink tests on non-unicode file systems. |
49 |
|
50 |
def test_get_unicode_symlink_target(self): |
|
51 |
self.requireFeature(tests.SymlinkFeature) |
|
52 |
tree = self.make_branch_and_tree('tree') |
|
53 |
try: |
|
54 |
os.symlink('target', u'tree/\u03b2_link'.encode(osutils._fs_enc)) |
|
55 |
except UnicodeError: |
|
56 |
raise tests.TestSkipped( |
|
57 |
'This platform does not support unicode file paths.') |
|
58 |
tree.add([u'\u03b2_link'], ['unicode-link-id']) |
|
59 |
tree.lock_read() |
|
60 |
self.addCleanup(tree.unlock) |
|
3949.6.1
by Jelmer Vernooij
Support symlinks with non-ascii characters in the symlink filename. |
61 |
self.assertEqual('target', tree.get_symlink_target(u'unicode-link-id')) |
62 |