~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Robert Collins
  • Date: 2007-01-29 16:58:49 UTC
  • mto: This revision was merged to the branch mainline in revision 2246.
  • Revision ID: robertc@robertcollins.net-20070129165849-409f5714fa7ebe48
New Branch hooks facility, with one initial hook 'set_rh' which triggers
whenever the revision history is set. This allows triggering on e.g.
push, pull, commit, and so on. Developed for use with the branchrss
plugin. See bzrlib/tests/branch_implementations/test_hooks for more
details. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
569
569
        self._startLogFile()
570
570
        self._benchcalls = []
571
571
        self._benchtime = None
 
572
        # prevent hooks affecting tests
 
573
        self._preserved_hooks = bzrlib.branch.Branch.hooks
 
574
        self.addCleanup(self._restoreHooks)
 
575
        # this list of hooks must be kept in sync with the defaults
 
576
        # in branch.py
 
577
        bzrlib.branch.Branch.hooks = bzrlib.branch.Branch.DefaultHooks()
572
578
 
573
579
    def _silenceUI(self):
574
580
        """Turn off UI for duration of test"""
835
841
        for name, value in self.__old_env.iteritems():
836
842
            osutils.set_or_unset_env(name, value)
837
843
 
 
844
    def _restoreHooks(self):
 
845
        bzrlib.branch.Branch.hooks = self._preserved_hooks
 
846
 
838
847
    def tearDown(self):
839
848
        self._runCleanups()
840
849
        unittest.TestCase.tearDown(self)