~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-01 04:42:04 UTC
  • mfrom: (4314.2.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090501044204-tvp4oeoj89zr9fby
(robertc) Add debugging of lock activity during tests. (Robert
        Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib import (
29
29
    branchbuilder,
30
30
    bzrdir,
 
31
    debug,
31
32
    errors,
 
33
    lockdir,
32
34
    memorytree,
33
35
    osutils,
34
36
    remote,
619
621
        # But we have a safety net in place.
620
622
        self.assertRaises(AssertionError, self._check_safety_net)
621
623
 
 
624
    def test_dangling_locks_cause_failures(self):
 
625
        # This is currently only enabled during debug runs, so turn debugging
 
626
        # on.
 
627
        debug.debug_flags.add('lock')
 
628
        class TestDanglingLock(TestCaseWithMemoryTransport):
 
629
            def test_function(self):
 
630
                t = self.get_transport('.')
 
631
                l = lockdir.LockDir(t, 'lock')
 
632
                l.create()
 
633
                l.attempt_lock()
 
634
        test = TestDanglingLock('test_function')
 
635
        result = test.run()
 
636
        self.assertEqual(1, len(result.errors))
 
637
 
622
638
 
623
639
class TestTestCaseWithTransport(TestCaseWithTransport):
624
640
    """Tests for the convenience functions TestCaseWithTransport introduces."""