/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

Start addressing test failing when run with -Dlock.

* tests/test_lockdir.py:
Fix 7 out 10 failures when using -Dlock.

* lock.py:
(LockResult.__repr__): For debug and to make 'Broken test' traces
less obscure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
        lf1 = LockDir(t, 'test_lock')
143
143
        lf1.create()
144
144
        lf1.attempt_lock()
 
145
        self.addCleanup(lf1.unlock)
145
146
        # lock is held, should get some info on it
146
147
        info1 = lf1.peek()
147
148
        self.assertEqual(set(info1.keys()),
161
162
        lf2 = LockDir(self.get_readonly_transport(), 'test_lock')
162
163
        self.assertEqual(lf2.peek(), None)
163
164
        lf1.attempt_lock()
 
165
        self.addCleanup(lf1.unlock)
164
166
        info2 = lf2.peek()
165
167
        self.assertTrue(info2)
166
168
        self.assertEqual(info2['nonce'], lf1.nonce)
451
453
        lf1 = LockDir(t, 'test_lock')
452
454
        lf1.create()
453
455
        lf1.attempt_lock()
 
456
        self.addCleanup(lf1.unlock)
454
457
        lf1.confirm()
455
458
 
456
459
    def test_41_confirm_not_held(self):
468
471
        lf1.attempt_lock()
469
472
        t.move('test_lock', 'lock_gone_now')
470
473
        self.assertRaises(LockBroken, lf1.confirm)
 
474
        # Clean up
 
475
        t.move('lock_gone_now', 'test_lock')
 
476
        lf1.unlock()
471
477
 
472
478
    def test_43_break(self):
473
479
        """Break a lock whose caller has forgotten it"""
501
507
        lf2.force_break(holder_info)
502
508
        # now we should be able to take it
503
509
        lf2.attempt_lock()
 
510
        self.addCleanup(lf2.unlock)
504
511
        lf2.confirm()
505
512
 
506
513
    def test_45_break_mismatch(self):
621
628
    def test_lock_by_token(self):
622
629
        ld1 = self.get_lock()
623
630
        token = ld1.lock_write()
 
631
        self.addCleanup(ld1.unlock)
624
632
        self.assertNotEqual(None, token)
625
633
        ld2 = self.get_lock()
626
634
        t2 = ld2.lock_write(token)
 
635
        self.addCleanup(ld2.unlock)
627
636
        self.assertEqual(token, t2)
628
637
 
629
638
    def test_lock_with_buggy_rename(self):
654
663
        check_dir([])
655
664
        # when held, that's all we see
656
665
        ld1.attempt_lock()
 
666
        self.addCleanup(ld1.unlock)
657
667
        check_dir(['held'])
658
668
        # second guy should fail
659
669
        self.assertRaises(errors.LockContention, ld2.attempt_lock)