~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-11-08 13:45:51 UTC
  • mfrom: (5532.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20101108134551-sxvk77ehmegkrwmm
(vila) Fix news entry

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Tests for LockDir"""
18
18
 
 
19
from cStringIO import StringIO
19
20
import os
20
21
from threading import Thread, Lock
21
22
import time
33
34
    LockBreakMismatch,
34
35
    LockBroken,
35
36
    LockContention,
 
37
    LockError,
36
38
    LockFailed,
37
39
    LockNotHeld,
38
40
    )
39
41
from bzrlib.lockdir import LockDir
40
 
from bzrlib.tests import (
41
 
    features,
42
 
    TestCaseWithTransport,
43
 
    )
 
42
from bzrlib.tests import (features, TestCaseWithTransport)
44
43
from bzrlib.trace import note
45
44
 
46
45
# These tests sometimes use threads to test the behaviour of lock files with
581
580
                self.prompts.append(('boolean', prompt))
582
581
                return True
583
582
        ui = LoggingUIFactory()
584
 
        self.overrideAttr(bzrlib.ui, 'ui_factory', ui)
585
 
        ld2.break_lock()
586
 
        self.assertLength(1, ui.prompts)
587
 
        self.assertEqual('boolean', ui.prompts[0][0])
588
 
        self.assertStartsWith(ui.prompts[0][1], 'Break (corrupt LockDir')
589
 
        self.assertRaises(LockBroken, ld.unlock)
 
583
        orig_factory = bzrlib.ui.ui_factory
 
584
        bzrlib.ui.ui_factory = ui
 
585
        try:
 
586
            ld2.break_lock()
 
587
            self.assertLength(1, ui.prompts)
 
588
            self.assertEqual('boolean', ui.prompts[0][0])
 
589
            self.assertStartsWith(ui.prompts[0][1], 'Break (corrupt LockDir')
 
590
            self.assertRaises(LockBroken, ld.unlock)
 
591
        finally:
 
592
            bzrlib.ui.ui_factory = orig_factory
590
593
 
591
594
    def test_break_lock_missing_info(self):
592
595
        """break_lock works even if the info file is missing (and tells the UI
738
741
    def test_corrupt_lockdir_info(self):
739
742
        """We can cope with corrupt (and thus unparseable) info files."""
740
743
        # This seems like a fairly common failure case too - see
741
 
        # <https://bugs.launchpad.net/bzr/+bug/619872> for instance.
 
744
        # <https://bugs.edge.launchpad.net/bzr/+bug/619872> for instance.
742
745
        # In particular some systems tend to fill recently created files with
743
746
        # nul bytes after recovering from a system crash.
744
747
        t = self.get_transport()