/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/test_counted_lock.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009, 2016 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 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
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
 
"""Tests for breezy.counted_lock"""
 
17
"""Tests for bzrlib.counted_lock"""
18
18
 
19
 
from ..counted_lock import CountedLock
20
 
from ..errors import (
 
19
from bzrlib.counted_lock import CountedLock
 
20
from bzrlib.errors import (
21
21
    LockError,
22
22
    LockNotHeld,
23
23
    ReadOnlyError,
24
24
    TokenMismatch,
25
25
    )
26
 
from . import TestCase
 
26
from bzrlib.tests import TestCase
27
27
 
28
28
 
29
29
class DummyLock(object):
69
69
    def _assert_not_locked(self):
70
70
        if self._lock_mode:
71
71
            raise LockError("%s is already locked in mode %r" %
72
 
                            (self, self._lock_mode))
 
72
                (self, self._lock_mode))
73
73
 
74
74
    def validate_token(self, token):
75
75
        if token == 'token':
143
143
        self.assertTrue(l.is_locked())
144
144
        l.unlock()
145
145
        self.assertFalse(l.is_locked())
146
 
        self.assertEqual(
 
146
        self.assertEquals(
147
147
            ['lock_read', 'unlock'],
148
148
            real_lock._calls)
149
149
 
157
157
        l = CountedLock(real_lock)
158
158
        l.lock_write()
159
159
        l.lock_read()
160
 
        self.assertEqual('token', l.lock_write())
 
160
        self.assertEquals('token', l.lock_write())
161
161
        l.unlock()
162
162
        l.unlock()
163
163
        l.unlock()
164
164
        self.assertFalse(l.is_locked())
165
 
        self.assertEqual(
 
165
        self.assertEquals(
166
166
            ['lock_write', 'unlock'],
167
167
            real_lock._calls)
168
168
 
174
174
        self.assertRaises(ReadOnlyError, l.lock_write)
175
175
        l.unlock()
176
176
        self.assertFalse(l.is_locked())
177
 
        self.assertEqual(
 
177
        self.assertEquals(
178
178
            ['lock_read', 'unlock'],
179
179
            real_lock._calls)
180
180