/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 17:48:22 UTC
  • mto: (4987.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125174822-nce4l19sbwx83jvq
Deploying the new overrideAttr facility further reduces the complexity
and make the code clearer.

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.addAttrCleanup(bzrlib.ui, 'ui_factory')
40
35
 
41
36
    def test_unlocked(self):
42
37
        # break lock when nothing is locked should just return
57
52
        other_instance = self.branch.repository.bzrdir.open_repository()
58
53
        if not other_instance.get_physical_lock_status():
59
54
            raise TestNotApplicable("Repository does not lock persistently.")
60
 
        bzrlib.ui.ui_factory = CannedInputUIFactory([True])
 
55
        ui.ui_factory = ui.CannedInputUIFactory([True])
61
56
        try:
62
57
            self.unused_branch.break_lock()
63
58
        except NotImplementedError:
69
64
    def test_locked(self):
70
65
        # break_lock when locked should unlock the branch and repo
71
66
        self.branch.lock_write()
72
 
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True])
 
67
        ui.ui_factory = ui.CannedInputUIFactory([True, True])
73
68
        try:
74
69
            self.unused_branch.break_lock()
75
70
        except NotImplementedError:
88
83
            # this branch does not support binding.
89
84
            return
90
85
        master.lock_write()
91
 
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True])
 
86
        ui.ui_factory = ui.CannedInputUIFactory([True, True])
92
87
        try:
93
88
            self.unused_branch.break_lock()
94
89
        except NotImplementedError: