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

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import threading
22
22
import time
23
23
 
 
24
try:
 
25
    import paramiko
 
26
    paramiko_loaded = True
 
27
except ImportError:
 
28
    paramiko_loaded = False
 
29
 
24
30
from bzrlib import (
25
31
    bzrdir,
26
32
    errors,
38
44
from bzrlib.tests.HttpServer import HttpServer
39
45
from bzrlib.transport import get_transport
40
46
import bzrlib.transport.http
41
 
from bzrlib.transport.sftp import (
42
 
    SFTPAbsoluteServer,
43
 
    SFTPHomeDirServer,
44
 
    SFTPTransport,
45
 
    )
 
47
 
 
48
if paramiko_loaded:
 
49
    from bzrlib.transport.sftp import (
 
50
        SFTPAbsoluteServer,
 
51
        SFTPHomeDirServer,
 
52
        SFTPTransport,
 
53
        )
 
54
 
46
55
from bzrlib.workingtree import WorkingTree
47
56
 
48
 
try:
49
 
    import paramiko
50
 
    paramiko_loaded = True
51
 
except ImportError:
52
 
    paramiko_loaded = False
53
 
 
54
57
 
55
58
def set_test_transport_to_sftp(testcase):
56
59
    """A helper to set transports on test case instances."""
105
108
    """Test the SFTP transport with homedir based relative paths."""
106
109
 
107
110
    def test__remote_path(self):
 
111
        if sys.platform == 'darwin':
 
112
            # This test is about sftp absolute path handling. There is already
 
113
            # (in this test) a TODO about windows needing an absolute path
 
114
            # without drive letter. To me, using self.test_dir is a trick to
 
115
            # get an absolute path for comparison purposes.  That fails for OSX
 
116
            # because the sftp server doesn't resolve the links (and it doesn't
 
117
            # have to). --vila 20070924
 
118
            self.knownFailure('Mac OSX symlinks /tmp to /private/tmp,'
 
119
                              ' testing against self.test_dir'
 
120
                              ' is not appropriate')
108
121
        t = self.get_transport()
109
122
        # This test require unix-like absolute path
110
123
        test_dir = self.test_dir
115
128
            test_dir = '/' + test_dir
116
129
        # try what is currently used:
117
130
        # remote path = self._abspath(relpath)
118
 
        self.assertEqual(test_dir + '/relative', t._remote_path('relative'))
 
131
        self.assertIsSameRealPath(test_dir + '/relative',
 
132
                                  t._remote_path('relative'))
119
133
        # we dont os.path.join because windows gives us the wrong path
120
134
        root_segments = test_dir.split('/')
121
135
        root_parent = '/'.join(root_segments[:-1])
122
136
        # .. should be honoured
123
 
        self.assertEqual(root_parent + '/sibling', t._remote_path('../sibling'))
 
137
        self.assertIsSameRealPath(root_parent + '/sibling',
 
138
                                  t._remote_path('../sibling'))
124
139
        # /  should be illegal ?
125
140
        ### FIXME decide and then test for all transports. RBC20051208
126
141