~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Robert Collins
  • Date: 2007-03-25 08:59:56 UTC
  • mto: (2376.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2401.
  • Revision ID: robertc@robertcollins.net-20070325085956-my8jv7cifqzyltyz
New SmartServer hooks facility. There are two initial hooks documented
in bzrlib.transport.smart.SmartServerHooks. The two initial hooks allow
plugins to execute code upon server startup and shutdown.
(Robert Collins).

SmartServer in standalone mode will now close its listening socket
when it stops, rather than waiting for garbage collection. This primarily
fixes test suite hangs when a test tries to connect to a shutdown server.
It may also help improve behaviour when dealing with a server running
on a specific port (rather than dynamically assigned ports).
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
680
680
        self._benchcalls = []
681
681
        self._benchtime = None
682
682
        # prevent hooks affecting tests
683
 
        self._preserved_hooks = bzrlib.branch.Branch.hooks
 
683
        self._preserved_hooks = {
 
684
            bzrlib.branch.Branch:bzrlib.branch.Branch.hooks,
 
685
            bzrlib.transport.smart.SmartTCPServer:bzrlib.transport.smart.SmartTCPServer.hooks,
 
686
            }
684
687
        self.addCleanup(self._restoreHooks)
685
688
        # this list of hooks must be kept in sync with the defaults
686
689
        # in branch.py
968
971
            osutils.set_or_unset_env(name, value)
969
972
 
970
973
    def _restoreHooks(self):
971
 
        bzrlib.branch.Branch.hooks = self._preserved_hooks
 
974
        for klass, hooks in self._preserved_hooks.items():
 
975
            setattr(klass, 'hooks', hooks)
972
976
 
973
977
    def tearDown(self):
974
978
        self._runCleanups()