summaryrefslogtreecommitdiff
path: root/tests/test_lock.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2018-11-14 17:53:01 -0800
committerAndy McCurdy <andy@andymccurdy.com>2018-11-14 17:53:01 -0800
commitc99d2b98ff928a0709ee0453b60002e3e1254674 (patch)
treee63ce2289fab5d6d0ef4a8864b56184f41be9a2e /tests/test_lock.py
parent255f01036f6a8d10b4369eca9e491d13d3c3788a (diff)
downloadredis-py-c99d2b98ff928a0709ee0453b60002e3e1254674.tar.gz
raise a LockError when the context manager fails to acquire a lockv3-breaking-changes
Fixes #621 Fixes #927
Diffstat (limited to 'tests/test_lock.py')
-rw-r--r--tests/test_lock.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_lock.py b/tests/test_lock.py
index 9cbc2f8..a9ecf54 100644
--- a/tests/test_lock.py
+++ b/tests/test_lock.py
@@ -56,6 +56,12 @@ class TestLock(object):
assert r.get('foo') == lock.local.token
assert r.get('foo') is None
+ def test_context_manager_raises_when_locked_not_acquired(self, r):
+ r.set('foo', 'bar')
+ with pytest.raises(LockError):
+ with self.get_lock(r, 'foo', blocking_timeout=0.1):
+ pass
+
def test_high_sleep_raises_error(self, r):
"If sleep is higher than timeout, it should raise an error"
with pytest.raises(LockError):