Skip to content

Commit 8d37bd8

Browse files
committed
Improved coverage for lock call context
1 parent 1c6a019 commit 8d37bd8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/test_core_lock.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def test_rlock_block(this_lock):
6868

6969
# Override owner to force acquisition failure
7070
this_lock._owner = None
71-
print(this_lock._owner)
7271
# Assert not owner
7372
assert not this_lock._is_owned()
7473

@@ -88,22 +87,30 @@ def test_rlock_block(this_lock):
8887

8988
# Release lock, assert no owner
9089
assert not this_lock._is_owned()
91-
92-
def test_rlock_acquire_timeout(this_lock):
90+
91+
92+
def test_rlock_acquire_timeout_pass(this_lock):
93+
# Assert acquisition fails using context manager
94+
with this_lock(timeout=0.01) as result:
95+
assert result is True
96+
97+
assert not this_lock.locked()
98+
99+
100+
def test_rlock_acquire_timeout_fail(this_lock):
93101
from labthings.core.exceptions import LockError
94102

95103
# Acquire lock
96104
assert this_lock.acquire()
97105

98106
# Override owner to force acquisition failure
99107
this_lock._owner = None
100-
print(this_lock._owner)
101108
# Assert not owner
102109
assert not this_lock._is_owned()
103110

104111
# Assert acquisition fails using context manager
105112
with pytest.raises(LockError):
106-
with this_lock(timeout=0.01):
113+
with this_lock(timeout=0.01) as result:
107114
pass
108115

109116
# Force ownership

0 commit comments

Comments
 (0)