~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/transport_util.py

MergeĀ lp:~gz/bzr/path_from_environ_832028

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import bzrlib.hooks
 
18
from bzrlib import transport
18
19
from bzrlib.tests import features
19
20
 
20
21
# SFTPTransport offers better performances but relies on paramiko, if paramiko
34
35
 
35
36
from bzrlib.transport import (
36
37
    ConnectedTransport,
37
 
    get_transport,
38
38
    register_transport,
39
39
    register_urlparse_netloc_protocol,
40
40
    unregister_transport,
47
47
    """Dict-mapping hook name to a list of callables for transport hooks"""
48
48
 
49
49
    def __init__(self):
50
 
        super(TransportHooks, self).__init__()
 
50
        super(TransportHooks, self).__init__("bzrlib.tests.transport_util",
 
51
            "InstrumentedTransport.hooks")
51
52
        # Invoked when the transport has just created a new connection.
52
53
        # The api signature is (transport, connection, credentials)
53
54
        self['_set_connection'] = []
76
77
            fake_base, _from_transport=_from_transport)
77
78
        # The following is needed to minimize the effects of our trick above
78
79
        # while retaining the best compatibility.
79
 
        self._scheme = _hooked_scheme
80
 
        base = self._unsplit_url(self._scheme,
81
 
                                 self._user, self._password,
82
 
                                 self._host, self._port,
83
 
                                 self._path)
84
 
        super(ConnectedTransport, self).__init__(base)
 
80
        self._parsed_url.scheme = _hooked_scheme
 
81
        super(ConnectedTransport, self).__init__(str(self._parsed_url))
85
82
 
86
83
 
87
84
class ConnectionHookedTransport(InstrumentedTransport):
111
108
        # standard test support code will work and permit the server url
112
109
        # correctly.
113
110
        url = self.get_url()
114
 
        t = get_transport(url)
 
111
        t = transport.get_transport_from_url(url)
115
112
        if t.base.endswith('work/'):
116
113
            t = t.clone('../..')
117
114
        self.permit_url(t.base)