1
# Copyright (C) 2006 Canonical Ltd
1
# Copyright (C) 2006-2010 Canonical Ltd
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
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
17
17
"""Tests for repository break-lock."""
19
from cStringIO import StringIO
22
import bzrlib.errors as errors
23
from bzrlib.tests.per_repository.test_repository import TestCaseWithRepository
24
from bzrlib.transport import get_transport
25
from bzrlib.workingtree import WorkingTree
28
class TestBreakLock(TestCaseWithRepository):
23
from bzrlib.tests import per_repository
26
class TestBreakLock(per_repository.TestCaseWithRepository):
31
29
super(TestBreakLock, self).setUp()
32
30
self.unused_repo = self.make_repository('.')
33
31
self.repo = self.unused_repo.bzrdir.open_repository()
34
# we want a UI factory that accepts canned input for the tests:
35
# while SilentUIFactory still accepts stdin, we need to customise
37
self.old_factory = bzrlib.ui.ui_factory
38
self.addCleanup(self.restoreFactory)
39
bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
40
bzrlib.ui.ui_factory.stdin = StringIO("y\n")
42
def restoreFactory(self):
43
bzrlib.ui.ui_factory = self.old_factory
32
ui.ui_factory = ui.CannedInputUIFactory([True])
45
34
def test_unlocked(self):
46
35
# break lock when nothing is locked should just return