~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Alexander Belchenko
  • Date: 2012-03-29 08:34:13 UTC
  • mto: (6015.44.14 2.4)
  • mto: This revision was merged to the branch mainline in revision 6513.
  • Revision ID: bialix@ukr.net-20120329083413-d4bqqdtfn2yrxp4f
change st_dev, st_ino, st_uid, st_gid from int members to properties.

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