~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/transport_util.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

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 = []