~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/transport_util.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-30 11:45:54 UTC
  • mto: (5622.4.1 uninstall-hook)
  • mto: This revision was merged to the branch mainline in revision 5747.
  • Revision ID: jelmer@samba.org-20110330114554-zx7av89umf2dd9an
Don't require arguments to hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
class TransportHooks(bzrlib.hooks.Hooks):
47
47
    """Dict-mapping hook name to a list of callables for transport hooks"""
48
48
 
49
 
    def __init__(self, module_name, member_name):
50
 
        super(TransportHooks, self).__init__(module_name, member_name)
 
49
    def __init__(self):
 
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'] = []
64
65
class InstrumentedTransport(_backing_transport_class):
65
66
    """Instrumented transport class to test commands behavior"""
66
67
 
67
 
    hooks = TransportHooks("bzrlib.tests.transport_util", "InstrumentedTransport.hooks")
 
68
    hooks = TransportHooks()
68
69
 
69
70
    def __init__(self, base, _from_transport=None):
70
71
        if not base.startswith(_hooked_scheme + '://'):
125
126
        return url
126
127
 
127
128
    def start_logging_connections(self):
128
 
        self.overrideAttr(InstrumentedTransport, 'hooks', TransportHooks(
129
 
            "bzrlib.tests.transport_util", "InstrumentedTransport.hooks"))
 
129
        self.overrideAttr(InstrumentedTransport, 'hooks', TransportHooks())
130
130
        # We preserved the hooks class attribute. Now we install our hook.
131
131
        ConnectionHookedTransport.hooks.install_named_hook(
132
132
            '_set_connection', self._collect_connection, None)