Skip to content

Commit

Permalink
Add test demonstrating lock behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed May 10, 2022
1 parent ee6f02c commit 4b5534f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions walrus/tests/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ def raise_exception():

# In the event of an exception, the lock will still be released.
self.assertTrue(lock.acquire(block=False))

def test_lock_cleanup(self):
self.assertEqual(len(db), 0)
lock = db.lock('lock-a')
self.assertTrue(lock.acquire())
self.assertTrue(lock.release())
self.assertEqual(len(db), 1) # We have the lock event key.
self.assertEqual(db.lpop(lock.event), b'1')

0 comments on commit 4b5534f

Please sign in to comment.