From c64186e93e3452b0e04cc91e88d8537ec665751e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Kro=CC=88ker?= Date: Sun, 17 Dec 2023 10:56:48 +0100 Subject: [PATCH] more tests --- tests/test_locking.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/test_locking.py b/tests/test_locking.py index 99e016b..9b3da8e 100644 --- a/tests/test_locking.py +++ b/tests/test_locking.py @@ -17,19 +17,20 @@ def test_lock_release(): pass -def test_orphaned_lock_timeout(): - prev_timeout = locking.LOCK_TIMEOUT - locking.LOCK_TIMEOUT = 0.1 - lock = locking.WriteLock("db_orphaned") +def test_read_lock_release(): + read_lock = locking.ReadLock("test_db") + write_lock = locking.WriteLock("test_db") - lock._lock() - time.sleep(0.2) + # Acquire and release a read lock + with read_lock: + pass - # Trigger the removal of orphaned locks - ls = locking.FileLocksSnapshot(lock.need_lock) - assert len(ls.locks) == 0 + # Now attempt to acquire a write lock + with write_lock: + assert write_lock.has_lock is not None - locking.LOCK_TIMEOUT = prev_timeout + read_lock._unlock() + write_lock._unlock() def test_double_lock_exception(use_compression):