~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Patch Queue Manager
  • Date: 2015-04-21 05:32:33 UTC
  • mfrom: (6602.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20150421053233-x63rhby1q3612v2h
(richard-wilbur) (jelmer)Make bzr build reproducible for Debian. (Jelmer
 Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for LockDir"""
18
18
 
19
19
import os
20
 
import sys
21
20
import time
22
21
 
23
22
import bzrlib
44
43
from bzrlib.tests import (
45
44
    features,
46
45
    TestCase,
 
46
    TestCaseInTempDir,
47
47
    TestCaseWithTransport,
48
48
    )
49
 
from bzrlib.trace import note
50
49
 
51
50
# These tests are run on the default transport provided by the test framework
52
51
# (typically a local disk transport).  That can be changed by the --transport
434
433
        self.assertContainsRe(info_list['time_ago'], r'^\d+ seconds? ago$')
435
434
 
436
435
    def test_lock_without_email(self):
437
 
        global_config = config.GlobalConfig()
 
436
        global_config = config.GlobalStack()
438
437
        # Intentionally has no email address
439
 
        global_config.set_user_option('email', 'User Identity')
 
438
        global_config.set('email', 'User Identity')
440
439
        ld1 = self.get_lock()
441
440
        ld1.create()
442
441
        ld1.lock_write()
465
464
    def test_lock_with_buggy_rename(self):
466
465
        # test that lock acquisition handles servers which pretend they
467
466
        # renamed correctly but that actually fail
468
 
        t = transport.get_transport('brokenrename+' + self.get_url())
 
467
        t = transport.get_transport_from_url(
 
468
            'brokenrename+' + self.get_url())
469
469
        ld1 = LockDir(t, 'test_lock')
470
470
        ld1.create()
471
471
        ld1.attempt_lock()
655
655
        self.assertEqual([], self._calls)
656
656
 
657
657
 
658
 
class TestLockHeldInfo(TestCase):
 
658
class TestLockHeldInfo(TestCaseInTempDir):
659
659
    """Can get information about the lock holder, and detect whether they're
660
660
    still alive."""
661
661
 
684
684
 
685
685
    def test_lock_holder_dead_process(self):
686
686
        """Detect that the holder (this process) is still running."""
 
687
        self.overrideAttr(lockdir, 'get_host_name',
 
688
            lambda: 'aproperhostname')
687
689
        info = LockHeldInfo.for_this_process(None)
688
690
        info.info_dict['pid'] = '123123123'
689
 
        if sys.platform == 'win32':
690
 
            self.knownFailure(
691
 
                'live lock holder detection not implemented yet on win32')
692
691
        self.assertTrue(info.is_lock_holder_known_dead())
693
692
 
694
693
    def test_lock_holder_other_machine(self):
731
730
 
732
731
        This generates a warning but no other user interaction.
733
732
        """
 
733
        self.overrideAttr(lockdir, 'get_host_name',
 
734
            lambda: 'aproperhostname')
734
735
        # This is off by default at present; see the discussion in the bug.
735
736
        # If you change the default, don't forget to update the docs.
736
 
        config.GlobalConfig().set_user_option('locks.steal_dead', True)
 
737
        config.GlobalStack().set('locks.steal_dead', True)
737
738
        # Create a lock pretending to come from a different nonexistent
738
739
        # process on the same machine.
739
740
        l1 = LockDir(self.get_transport(), 'a',