~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Config files in bazaar home now use a lock

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    branch,
24
24
    bzrdir,
 
25
    config,
25
26
    errors,
26
27
    lockdir,
 
28
    osutils,
27
29
    tests,
28
30
    )
29
31
 
73
75
        # however, we dont test breaking the working tree because we
74
76
        # cannot accurately do so right now: the dirstate lock is held
75
77
        # by an os lock, and we need to spawn a separate process to lock it
76
 
        # thne kill -9 it.
 
78
        # then kill -9 it.
77
79
        # sketch of test:
78
80
        # lock most of the dir:
79
81
        self.wt.branch.lock_write()
101
103
        out, err = self.run_bzr('break-lock foo')
102
104
        self.assertEqual('', out)
103
105
        self.assertEqual('', err)
 
106
 
 
107
class TestConfigBreakLock(tests.TestCaseWithTransport):
 
108
 
 
109
    def setUp(self):
 
110
        super(TestConfigBreakLock, self).setUp()
 
111
        self.config_file_name = './my.conf'
 
112
        self.build_tree_contents([(self.config_file_name,
 
113
                                   '[DEFAULT]\none=1\n')])
 
114
        self.config = config.LockableConfig(file_name=self.config_file_name)
 
115
        self.config.lock_write()
 
116
 
 
117
    def test_create_pending_lock(self):
 
118
        self.addCleanup(self.config.unlock)
 
119
        self.assertTrue(self.config._lock.is_held)
 
120
 
 
121
    def test_break_lock(self):
 
122
        self.run_bzr('break-lock --config %s'
 
123
                     % osutils.dirname(self.config_file_name),
 
124
                     stdin="y\n")
 
125
        self.assertRaises(errors.LockBroken, self.config.unlock)
 
126