/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 breezy/tests/test_lockable_files.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
import bzrlib
18
 
from bzrlib import (
 
17
import breezy
 
18
from .. import (
19
19
    errors,
20
20
    lockdir,
21
21
    osutils,
22
22
    transport,
23
23
    )
24
 
from bzrlib.lockable_files import LockableFiles, TransportLock
25
 
from bzrlib.tests import (
 
24
from ..lockable_files import LockableFiles, TransportLock
 
25
from . import (
26
26
    TestCaseInTempDir,
27
27
    TestNotApplicable,
28
28
    )
29
 
from bzrlib.tests.test_smart import TestCaseWithSmartMedium
30
 
from bzrlib.tests.test_transactions import DummyWeave
31
 
from bzrlib.transactions import (PassThroughTransaction,
32
 
                                 ReadOnlyTransaction,
33
 
                                 WriteTransaction,
34
 
                                 )
 
29
from ..bzr.tests.test_smart import TestCaseWithSmartMedium
 
30
from .test_transactions import DummyWeave
 
31
from ..transactions import (PassThroughTransaction,
 
32
                            ReadOnlyTransaction,
 
33
                            WriteTransaction,
 
34
                            )
35
35
 
36
36
 
37
37
# these tests are applied in each parameterized suite for LockableFiles
76
76
            self.lockable.unlock()
77
77
            raise TestNotApplicable("%r is not breakable" % (self.lockable,))
78
78
        l2 = self.get_lockable()
79
 
        orig_factory = bzrlib.ui.ui_factory
 
79
        orig_factory = breezy.ui.ui_factory
80
80
        # silent ui - no need for stdout
81
 
        bzrlib.ui.ui_factory = bzrlib.ui.CannedInputUIFactory([True])
 
81
        breezy.ui.ui_factory = breezy.ui.CannedInputUIFactory([True])
82
82
        try:
83
83
            l2.break_lock()
84
84
        finally:
85
 
            bzrlib.ui.ui_factory = orig_factory
 
85
            breezy.ui.ui_factory = orig_factory
86
86
        try:
87
87
            l2.lock_write()
88
88
            l2.unlock()
119
119
            # This test does not apply, because this lockable refuses
120
120
            # tokens.
121
121
            return
122
 
        different_token = token + 'xxx'
 
122
        different_token = token + b'xxx'
123
123
        # Re-using the same lockable instance with a different token will
124
124
        # raise TokenMismatch.
125
125
        self.assertRaises(errors.TokenMismatch,
323
323
        lockable = LockableFiles(self.transport.clone('readonly'), 'test-lock',
324
324
                                 lockdir.LockDir)
325
325
        # The directory mode should be read-write-execute for the current user
326
 
        self.assertEqual(00700, lockable._dir_mode & 00700)
 
326
        self.assertEqual(0o0700, lockable._dir_mode & 0o0700)
327
327
        # Files should be read-write for the current user
328
 
        self.assertEqual(00600, lockable._file_mode & 00700)
 
328
        self.assertEqual(0o0600, lockable._file_mode & 0o0700)
329
329
 
330
330
 
331
331
class TestLockableFiles_RemoteLockDir(TestCaseWithSmartMedium,
340
340
        # defeat the purpose. We test the protocol implementation separately
341
341
        # in test_remote and test_smart as usual.
342
342
        b = self.make_branch('foo')
343
 
        self.addCleanup(b.bzrdir.transport.disconnect)
 
343
        self.addCleanup(b.controldir.transport.disconnect)
344
344
        self.transport = transport.get_transport_from_path('.')
345
345
        self.lockable = self.get_lockable()
346
346
 
347
347
    def get_lockable(self):
348
348
        # getting a new lockable involves opening a new instance of the branch
349
 
        branch = bzrlib.branch.Branch.open(self.get_url('foo'))
350
 
        self.addCleanup(branch.bzrdir.transport.disconnect)
 
349
        branch = breezy.branch.Branch.open(self.get_url('foo'))
 
350
        self.addCleanup(branch.controldir.transport.disconnect)
351
351
        return branch.control_files