~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-08 19:51:48 UTC
  • mfrom: (4345.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090508195148-cw1mw95i0qo39ggg
(vila) Fix some lock-related test failures

Show diffs side-by-side

added added

removed removed

Lines of Context:
862
862
        # matching has occured with -Dlock.
863
863
        # unhook:
864
864
        acquired_locks = [lock for action, lock in self._lock_actions
865
 
            if action == 'acquired']
 
865
                          if action == 'acquired']
866
866
        released_locks = [lock for action, lock in self._lock_actions
867
 
            if action == 'released']
 
867
                          if action == 'released']
 
868
        broken_locks = [lock for action, lock in self._lock_actions
 
869
                        if action == 'broken']
868
870
        # trivially, given the tests for lock acquistion and release, if we
869
 
        # have as many in each list, it should be ok.
870
 
        if len(acquired_locks) != len(released_locks):
871
 
            message = \
872
 
                ("Different number of acquired and released locks. (%s, %s)" %
873
 
                (acquired_locks, released_locks))
 
871
        # have as many in each list, it should be ok. Some lock tests also
 
872
        # break some locks on purpose and should be taken into account by
 
873
        # considering that breaking a lock is just a dirty way of releasing it.
 
874
        if len(acquired_locks) != (len(released_locks) + len(broken_locks)):
 
875
            message = ('Different number of acquired and '
 
876
                       'released or broken locks. (%s, %s + %s)' %
 
877
                       (acquired_locks, released_locks, broken_locks))
874
878
            if not self._lock_check_thorough:
875
879
                # Rather than fail, just warn
876
880
                print "Broken test %s: %s" % (self, message)
882
886
        self._lock_actions = []
883
887
        self._lock_check_thorough = 'lock' in debug.debug_flags
884
888
        self.addCleanup(self._check_locks)
885
 
        _mod_lock.Lock.hooks.install_named_hook('lock_acquired', self._lock_acquired, None)
886
 
        _mod_lock.Lock.hooks.install_named_hook('lock_released', self._lock_released, None)
 
889
        _mod_lock.Lock.hooks.install_named_hook('lock_acquired',
 
890
                                                self._lock_acquired, None)
 
891
        _mod_lock.Lock.hooks.install_named_hook('lock_released',
 
892
                                                self._lock_released, None)
 
893
        _mod_lock.Lock.hooks.install_named_hook('lock_broken',
 
894
                                                self._lock_broken, None)
887
895
 
888
896
    def _lock_acquired(self, result):
889
897
        self._lock_actions.append(('acquired', result))
891
899
    def _lock_released(self, result):
892
900
        self._lock_actions.append(('released', result))
893
901
 
 
902
    def _lock_broken(self, result):
 
903
        self._lock_actions.append(('broken', result))
 
904
 
894
905
    def _ndiff_strings(self, a, b):
895
906
        """Return ndiff between two strings containing lines.
896
907