~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

lock_read and lock_write may raise TransportNotPossible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1013
1013
        self.check_transport_contents('bar', transport2, 'foo')
1014
1014
 
1015
1015
    def test_lock_write(self):
 
1016
        """Test transport-level write locks.
 
1017
 
 
1018
        These are deprecated and transports may decline to support them.
 
1019
        """
1016
1020
        transport = self.get_transport()
1017
1021
        if transport.is_readonly():
1018
1022
            self.assertRaises(TransportNotPossible, transport.lock_write, 'foo')
1019
1023
            return
1020
1024
        transport.put('lock', StringIO())
1021
 
        lock = transport.lock_write('lock')
 
1025
        try:
 
1026
            lock = transport.lock_write('lock')
 
1027
        except TransportNotPossible:
 
1028
            return
1022
1029
        # TODO make this consistent on all platforms:
1023
1030
        # self.assertRaises(LockError, transport.lock_write, 'lock')
1024
1031
        lock.unlock()
1025
1032
 
1026
1033
    def test_lock_read(self):
 
1034
        """Test transport-level read locks.
 
1035
 
 
1036
        These are deprecated and transports may decline to support them.
 
1037
        """
1027
1038
        transport = self.get_transport()
1028
1039
        if transport.is_readonly():
1029
1040
            file('lock', 'w').close()
1030
1041
        else:
1031
1042
            transport.put('lock', StringIO())
1032
 
        lock = transport.lock_read('lock')
 
1043
        try:
 
1044
            lock = transport.lock_read('lock')
 
1045
        except TransportNotPossible:
 
1046
            return
1033
1047
        # TODO make this consistent on all platforms:
1034
1048
        # self.assertRaises(LockError, transport.lock_read, 'lock')
1035
1049
        lock.unlock()