~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2009-08-04 04:36:34 UTC
  • mfrom: (4583 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090804043634-2iu9wpcgs273i97s
Merge bzr.dev.

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
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:
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: