~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/transport_util.py

  • Committer: Ian Clatworthy
  • Date: 2010-02-19 03:02:07 UTC
  • mto: (4797.23.1 integration-2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: ian.clatworthy@canonical.com-20100219030207-zpbzx021zavx4sqt
What's New in 2.1 - a summary of changes since 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
    def setUp(self):
101
101
        register_urlparse_netloc_protocol(_hooked_scheme)
102
102
        register_transport(_hooked_scheme, ConnectionHookedTransport)
103
 
        self.addCleanup(unregister_transport, _hooked_scheme,
104
 
                        ConnectionHookedTransport)
105
 
        self.addCleanup(_unregister_urlparse_netloc_protocol, _hooked_scheme)
 
103
 
 
104
        def unregister():
 
105
            unregister_transport(_hooked_scheme, ConnectionHookedTransport)
 
106
            _unregister_urlparse_netloc_protocol(_hooked_scheme)
 
107
 
 
108
        self.addCleanup(unregister)
106
109
        super(TestCaseWithConnectionHookedTransport, self).setUp()
107
110
        self.reset_connections()
108
111
        # Add the 'hooked' url to the permitted url list.
125
128
        return url
126
129
 
127
130
    def start_logging_connections(self):
128
 
        self.overrideAttr(InstrumentedTransport, 'hooks', TransportHooks())
129
 
        # We preserved the hooks class attribute. Now we install our hook.
130
131
        ConnectionHookedTransport.hooks.install_named_hook(
131
132
            '_set_connection', self._collect_connection, None)
 
133
        # uninstall our hooks when we are finished
 
134
        self.addCleanup(self.reset_hooks)
 
135
 
 
136
    def reset_hooks(self):
 
137
        InstrumentedTransport.hooks = TransportHooks()
132
138
 
133
139
    def reset_connections(self):
134
140
        self.connections = []