~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_break_lock.py

Merge cleanup into description

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from cStringIO import StringIO
20
20
 
21
 
import bzrlib
22
 
import bzrlib.errors as errors
 
21
from  bzrlib import (
 
22
    errors,
 
23
    ui,
 
24
    )
23
25
from bzrlib.tests import TestCase, TestCaseWithTransport, TestNotApplicable
24
26
from bzrlib.tests.per_branch.test_branch import TestCaseWithBranch
25
 
from bzrlib.ui import (
26
 
    CannedInputUIFactory,
27
 
    )
28
27
 
29
28
 
30
29
class TestBreakLock(TestCaseWithBranch):
33
32
        super(TestBreakLock, self).setUp()
34
33
        self.unused_branch = self.make_branch('branch')
35
34
        self.branch = self.unused_branch.bzrdir.open_branch()
36
 
        # we want a UI factory that accepts canned input for the tests:
37
 
        # while SilentUIFactory still accepts stdin, we need to customise
38
 
        # ours
39
 
        self.old_factory = bzrlib.ui.ui_factory
40
 
        self.addCleanup(self.restoreFactory)
41
 
 
42
 
    def restoreFactory(self):
43
 
        bzrlib.ui.ui_factory = self.old_factory
44
35
 
45
36
    def test_unlocked(self):
46
37
        # break lock when nothing is locked should just return
61
52
        other_instance = self.branch.repository.bzrdir.open_repository()
62
53
        if not other_instance.get_physical_lock_status():
63
54
            raise TestNotApplicable("Repository does not lock persistently.")
64
 
        bzrlib.ui.ui_factory = CannedInputUIFactory([True])
 
55
        ui.ui_factory = ui.CannedInputUIFactory([True])
65
56
        try:
66
57
            self.unused_branch.break_lock()
67
58
        except NotImplementedError:
73
64
    def test_locked(self):
74
65
        # break_lock when locked should unlock the branch and repo
75
66
        self.branch.lock_write()
76
 
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True])
 
67
        ui.ui_factory = ui.CannedInputUIFactory([True, True])
77
68
        try:
78
69
            self.unused_branch.break_lock()
79
70
        except NotImplementedError:
92
83
            # this branch does not support binding.
93
84
            return
94
85
        master.lock_write()
95
 
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True])
 
86
        ui.ui_factory = ui.CannedInputUIFactory([True, True])
96
87
        try:
97
88
            self.unused_branch.break_lock()
98
89
        except NotImplementedError: