~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Martin Pool
  • Date: 2006-02-21 22:30:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060221223022-0d73c36b63fc9bcf
New LockDir.force_break and simple test case

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
        lf1.attempt_lock()
216
216
        t.move('test_lock', 'lock_gone_now')
217
217
        self.assertRaises(LockBroken, lf1.confirm)
 
218
 
 
219
    def test_43_break(self):
 
220
        """Break a lock whose caller has forgotten it"""
 
221
        t = self.get_transport()
 
222
        lf1 = LockDir(t, 'test_lock')
 
223
        lf1.attempt_lock()
 
224
        # we incorrectly discard the lock object without unlocking it
 
225
        del lf1
 
226
        # someone else sees it's still locked
 
227
        lf2 = LockDir(t, 'test_lock')
 
228
        self.assertTrue(lf2.peek())
 
229
        lf2.force_break()
 
230
        # now we should be able to take it
 
231
        lf2.attempt_lock()
 
232
        lf2.confirm()