From b0d7af3482d4aa8feffcaaee81d4d125769f70b7 Mon Sep 17 00:00:00 2001 From: Andy McCurdy Date: Wed, 14 Nov 2018 20:59:54 -0800 Subject: 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 --- tests/test_lock.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/test_lock.py') 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') -- cgit v1.2.1