Commit 84152b96 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add a few SharedLock delete() tests

- Check that even a shared acquire() fails on a deleted lock
- Check that delete() fails on a lock you share (must own it or nothing)

These are assumptions I build on in future code, so better check for them.
Currently no code change is necessary for them to be valid.

Reviewed-by: iustinp
parent 4354ab03
...@@ -192,8 +192,13 @@ class TestSharedLock(unittest.TestCase): ...@@ -192,8 +192,13 @@ class TestSharedLock(unittest.TestCase):
def testDelete(self): def testDelete(self):
self.sl.delete() self.sl.delete()
self.assertRaises(errors.LockError, self.sl.acquire) self.assertRaises(errors.LockError, self.sl.acquire)
self.assertRaises(errors.LockError, self.sl.acquire, shared=1)
self.assertRaises(errors.LockError, self.sl.delete) self.assertRaises(errors.LockError, self.sl.delete)
def testNoDeleteIfSharer(self):
self.sl.acquire(shared=1)
self.assertRaises(AssertionError, self.sl.delete)
def testDeletePendingSharersExclusiveDelete(self): def testDeletePendingSharersExclusiveDelete(self):
self.sl.acquire() self.sl.acquire()
Thread(target=self._doItSharer).start() Thread(target=self._doItSharer).start()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment