~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: John Arbash Meinel
  • Date: 2012-06-08 06:59:50 UTC
  • mto: (6015.57.2 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: john@arbash-meinel.com-20120608065950-3ldv3l9qal3g1rtu
Fix bug #1010339.

'bzr testament' should use exact encoding for its output. It previously simulated
this by using sys.stdout directly, but that does not set binary mode on Windows.

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
45
46
    TestCase,
46
47
    TestCaseWithTransport,
47
48
    )
 
49
from bzrlib.trace import note
48
50
 
49
51
# These tests are run on the default transport provided by the test framework
50
52
# (typically a local disk transport).  That can be changed by the --transport
463
465
    def test_lock_with_buggy_rename(self):
464
466
        # test that lock acquisition handles servers which pretend they
465
467
        # renamed correctly but that actually fail
466
 
        t = transport.get_transport_from_url(
467
 
            'brokenrename+' + self.get_url())
 
468
        t = transport.get_transport('brokenrename+' + self.get_url())
468
469
        ld1 = LockDir(t, 'test_lock')
469
470
        ld1.create()
470
471
        ld1.attempt_lock()
683
684
 
684
685
    def test_lock_holder_dead_process(self):
685
686
        """Detect that the holder (this process) is still running."""
686
 
        self.overrideAttr(lockdir, 'get_host_name',
687
 
            lambda: 'aproperhostname')
688
687
        info = LockHeldInfo.for_this_process(None)
689
688
        info.info_dict['pid'] = '123123123'
 
689
        if sys.platform == 'win32':
 
690
            self.knownFailure(
 
691
                'live lock holder detection not implemented yet on win32')
690
692
        self.assertTrue(info.is_lock_holder_known_dead())
691
693
 
692
694
    def test_lock_holder_other_machine(self):
729
731
 
730
732
        This generates a warning but no other user interaction.
731
733
        """
732
 
        self.overrideAttr(lockdir, 'get_host_name',
733
 
            lambda: 'aproperhostname')
734
734
        # This is off by default at present; see the discussion in the bug.
735
735
        # If you change the default, don't forget to update the docs.
736
736
        config.GlobalConfig().set_user_option('locks.steal_dead', True)