/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: Andrew Bennetts
  • Date: 2010-01-12 03:53:21 UTC
  • mfrom: (4948 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: andrew.bennetts@canonical.com-20100112035321-hofpz5p10224ryj3
Merge lp:bzr, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2009 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for branch break-lock behaviour."""
18
18
 
21
21
import bzrlib
22
22
import bzrlib.errors as errors
23
23
from bzrlib.tests import TestCase, TestCaseWithTransport, TestNotApplicable
24
 
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
 
24
from bzrlib.tests.per_branch.test_branch import TestCaseWithBranch
 
25
from bzrlib.ui import (
 
26
    CannedInputUIFactory,
 
27
    )
25
28
 
26
29
 
27
30
class TestBreakLock(TestCaseWithBranch):
35
38
        # ours
36
39
        self.old_factory = bzrlib.ui.ui_factory
37
40
        self.addCleanup(self.restoreFactory)
38
 
        bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
39
41
 
40
42
    def restoreFactory(self):
41
43
        bzrlib.ui.ui_factory = self.old_factory
59
61
        other_instance = self.branch.repository.bzrdir.open_repository()
60
62
        if not other_instance.get_physical_lock_status():
61
63
            raise TestNotApplicable("Repository does not lock persistently.")
62
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
 
64
        bzrlib.ui.ui_factory = CannedInputUIFactory([True])
63
65
        try:
64
66
            self.unused_branch.break_lock()
65
67
        except NotImplementedError:
71
73
    def test_locked(self):
72
74
        # break_lock when locked should unlock the branch and repo
73
75
        self.branch.lock_write()
74
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\n")
 
76
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True])
75
77
        try:
76
78
            self.unused_branch.break_lock()
77
79
        except NotImplementedError:
81
83
        self.assertRaises(errors.LockBroken, self.branch.unlock)
82
84
 
83
85
    def test_unlocks_master_branch(self):
84
 
        # break_lock when when the master branch is locked should offer to
 
86
        # break_lock when the master branch is locked should offer to
85
87
        # unlock it.
86
88
        master = self.make_branch('master')
87
89
        try:
90
92
            # this branch does not support binding.
91
93
            return
92
94
        master.lock_write()
93
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\n")
 
95
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True])
94
96
        try:
95
97
            self.unused_branch.break_lock()
96
98
        except NotImplementedError: