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

(Martin Pool) Make it optional for transports to implement lock_read and lock_write by testing that they either work or raise TransportNotPossible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1227
1227
        self.check_transport_contents('bar', transport2, 'foo')
1228
1228
 
1229
1229
    def test_lock_write(self):
 
1230
        """Test transport-level write locks.
 
1231
 
 
1232
        These are deprecated and transports may decline to support them.
 
1233
        """
1230
1234
        transport = self.get_transport()
1231
1235
        if transport.is_readonly():
1232
1236
            self.assertRaises(TransportNotPossible, transport.lock_write, 'foo')
1233
1237
            return
1234
1238
        transport.put_bytes('lock', '')
1235
 
        lock = transport.lock_write('lock')
 
1239
        transport.put('lock', StringIO())
 
1240
        try:
 
1241
            lock = transport.lock_write('lock')
 
1242
        except TransportNotPossible:
 
1243
            return
1236
1244
        # TODO make this consistent on all platforms:
1237
1245
        # self.assertRaises(LockError, transport.lock_write, 'lock')
1238
1246
        lock.unlock()
1239
1247
 
1240
1248
    def test_lock_read(self):
 
1249
        """Test transport-level read locks.
 
1250
 
 
1251
        These are deprecated and transports may decline to support them.
 
1252
        """
1241
1253
        transport = self.get_transport()
1242
1254
        if transport.is_readonly():
1243
1255
            file('lock', 'w').close()
1244
1256
        else:
1245
1257
            transport.put_bytes('lock', '')
1246
 
        lock = transport.lock_read('lock')
 
1258
        try:
 
1259
            lock = transport.lock_read('lock')
 
1260
        except TransportNotPossible:
 
1261
            return
1247
1262
        # TODO make this consistent on all platforms:
1248
1263
        # self.assertRaises(LockError, transport.lock_read, 'lock')
1249
1264
        lock.unlock()