/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_workingtree/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
from cStringIO import StringIO
19
19
import os
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 TestNotApplicable
24
26
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
25
27
 
28
30
 
29
31
    def setUp(self):
30
32
        super(TestBreakLock, self).setUp()
31
 
        self.addAttrCleanup(bzrlib.ui, 'ui_factory')
32
33
        self.unused_workingtree = self.make_branch_and_tree('.')
33
34
        self.workingtree = self.unused_workingtree.bzrdir.open_workingtree()
34
35
 
44
45
        # if the workingtree isn't locked - and the easiest way
45
46
        # to see if that happened is to lock the repo.
46
47
        self.workingtree.branch.repository.lock_write()
47
 
        bzrlib.ui.ui_factory = bzrlib.ui.CannedInputUIFactory([True])
 
48
        ui.ui_factory = ui.CannedInputUIFactory([True])
48
49
        try:
49
50
            self.unused_workingtree.break_lock()
50
51
        except NotImplementedError:
51
52
            # workingtree does not support break_lock
52
53
            self.workingtree.branch.repository.unlock()
53
54
            return
54
 
        if bzrlib.ui.ui_factory.responses == [True]:
 
55
        if ui.ui_factory.responses == [True]:
55
56
            raise TestNotApplicable("repository does not physically lock.")
56
57
        self.assertRaises(errors.LockBroken,
57
58
            self.workingtree.branch.repository.unlock)
59
60
    def test_locked(self):
60
61
        # break_lock when locked should
61
62
        self.workingtree.lock_write()
62
 
        bzrlib.ui.ui_factory = bzrlib.ui.CannedInputUIFactory([True, True, True])
 
63
        ui.ui_factory = ui.CannedInputUIFactory([True, True, True])
63
64
        try:
64
65
            self.unused_workingtree.break_lock()
65
66
        except (NotImplementedError, errors.LockActive):