diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2018-11-14 20:59:54 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2018-11-14 21:01:08 -0800 |
commit | b0d7af3482d4aa8feffcaaee81d4d125769f70b7 (patch) | |
tree | 1b78eeccb0d989b7776596caad9fb9df75013c89 /tests/test_lock.py | |
parent | 7435603ac4f097f8f9d187b9b665364666cfee9e (diff) | |
download | redis-py-b0d7af3482d4aa8feffcaaee81d4d125769f70b7.tar.gz |
add locked() method to lock object
Lock.locked() returns a boolean indicating if the lock is acquired and valid.
Thanks Alan Justino da Silva
Fixes #1007
Diffstat (limited to 'tests/test_lock.py')
-rw-r--r-- | tests/test_lock.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_lock.py b/tests/test_lock.py index a9ecf54..a6adbc2 100644 --- a/tests/test_lock.py +++ b/tests/test_lock.py @@ -18,6 +18,14 @@ class TestLock(object): lock.release() assert r.get('foo') is None + def test_locked(self, r): + lock = self.get_lock(r, 'foo') + assert lock.locked() is False + lock.acquire(blocking=False) + assert lock.locked() is True + lock.release() + assert lock.locked() is False + def test_competing_locks(self, r): lock1 = self.get_lock(r, 'foo') lock2 = self.get_lock(r, 'foo') |