~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-10-10 01:05:01 UTC
  • mfrom: (2872.5.5 129701-readonly-commit)
  • Revision ID: pqm@pqm.ubuntu.com-20071010010501-ejbj03m5w3k9vdsd
Avoid internal error tracebacks on failure to lock on readonly transport (#129701)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 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
30
30
    transport,
31
31
    )
32
32
from bzrlib.errors import (
33
 
        LockBreakMismatch,
34
 
        LockContention, LockError, UnlockableTransport,
35
 
        LockNotHeld, LockBroken
36
 
        )
 
33
    LockBreakMismatch,
 
34
    LockBroken,
 
35
    LockContention,
 
36
    LockError,
 
37
    LockFailed,
 
38
    LockNotHeld,
 
39
    )
37
40
from bzrlib.lockdir import LockDir
38
41
from bzrlib.tests import TestCaseWithTransport
39
42
from bzrlib.trace import note
105
108
        """Fail to create lock on readonly transport"""
106
109
        t = self.get_readonly_transport()
107
110
        lf = LockDir(t, 'test_lock')
108
 
        self.assertRaises(UnlockableTransport, lf.create)
 
111
        self.assertRaises(LockFailed, lf.create)
109
112
 
110
113
    def test_12_lock_readonly_transport(self):
111
114
        """Fail to lock on readonly transport"""
112
115
        lf = LockDir(self.get_transport(), 'test_lock')
113
116
        lf.create()
114
117
        lf = LockDir(self.get_readonly_transport(), 'test_lock')
115
 
        self.assertRaises(UnlockableTransport, lf.attempt_lock)
 
118
        self.assertRaises(LockFailed, lf.attempt_lock)
116
119
 
117
120
    def test_20_lock_contested(self):
118
121
        """Contention to get a lock"""
599
602
        lock_path = ld1.transport.local_abspath('test_lock')
600
603
        os.mkdir(lock_path)
601
604
        osutils.make_readonly(lock_path)
602
 
        self.assertRaises(errors.PermissionDenied, ld1.attempt_lock)
 
605
        self.assertRaises(errors.LockFailed, ld1.attempt_lock)
603
606
 
604
607
    def test_lock_by_token(self):
605
608
        ld1 = self.get_lock()