Skip to content

Commit b45d68d

Browse files
committed
Added tests for not blocking lock timeout
1 parent 9cecd04 commit b45d68d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tests/test_backend.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,15 +677,27 @@ def test_expire_at(self, cache: RedisCache):
677677

678678
def test_lock(self, cache: RedisCache):
679679
lock = cache.lock("foobar")
680-
lock.acquire(blocking=True)
680+
assert lock.acquire(blocking=True)
681+
682+
assert cache.has_key("foobar")
683+
lock.release()
684+
assert not cache.has_key("foobar")
685+
686+
def test_lock_not_blocking(self, cache: RedisCache):
687+
lock = cache.lock("foobar")
688+
assert lock.acquire(blocking=False)
689+
690+
lock2 = cache.lock("foobar")
691+
692+
assert not lock2.acquire(blocking=False)
681693

682694
assert cache.has_key("foobar")
683695
lock.release()
684696
assert not cache.has_key("foobar")
685697

686698
def test_lock_released_by_thread(self, cache: RedisCache):
687699
lock = cache.lock("foobar", thread_local=False)
688-
lock.acquire(blocking=True)
700+
assert lock.acquire(blocking=True)
689701

690702
def release_lock(lock_):
691703
lock_.release()

0 commit comments

Comments
 (0)