~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-30 20:44:21 UTC
  • mto: This revision was merged to the branch mainline in revision 4611.
  • Revision ID: john@arbash-meinel.com-20090730204421-ei0b6opu4h9njsta
Remove -Dlock from the test suite, in preparation for using it elsewhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
802
802
        self._benchcalls = []
803
803
        self._benchtime = None
804
804
        self._clear_hooks()
805
 
        # Track locks - needs to be called before _clear_debug_flags.
806
805
        self._track_locks()
807
806
        self._clear_debug_flags()
808
807
        TestCase._active_threads = threading.activeCount()
859
858
    def _check_locks(self):
860
859
        """Check that all lock take/release actions have been paired."""
861
860
        # once we have fixed all the current lock problems, we can change the
862
 
        # following code to always check for mismatched locks, but only do
863
 
        # traceback showing with -Dlock (self._lock_check_thorough is True).
864
 
        # For now, because the test suite will fail, we only assert that lock
865
 
        # matching has occured with -Dlock.
 
861
        # following code to always check for mismatched locks
866
862
        # unhook:
867
863
        acquired_locks = [lock for action, lock in self._lock_actions
868
864
                          if action == 'acquired']
878
874
            message = ('Different number of acquired and '
879
875
                       'released or broken locks. (%s, %s + %s)' %
880
876
                       (acquired_locks, released_locks, broken_locks))
881
 
            if not self._lock_check_thorough:
882
 
                # Rather than fail, just warn
883
 
                print "Broken test %s: %s" % (self, message)
884
 
                return
885
877
            self.fail(message)
886
878
 
887
879
    def _track_locks(self):
888
880
        """Track lock activity during tests."""
889
881
        self._lock_actions = []
890
 
        self._lock_check_thorough = 'lock' not in debug.debug_flags
891
882
        self.addCleanup(self._check_locks)
892
883
        _mod_lock.Lock.hooks.install_named_hook('lock_acquired',
893
884
                                                self._lock_acquired, None)