Skip to content

Commit 029773a

Browse files
committed
release pushes the token back in
1 parent ffd5c03 commit 029773a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

packages/service-library/tests/redis/test_semaphore.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ async def test_semaphore_acquire_release_basic(
199199
)
200200

201201
# reacquire after release should fail
202-
with pytest.raises(
203-
SemaphoreNotAcquiredError,
204-
match=f"Semaphore '{semaphore_name}' was not acquired by this instance",
205-
):
202+
with pytest.raises(SemaphoreNotAcquiredError):
206203
await semaphore.reacquire()
207204
await _assert_semaphore_redis_state(
208205
redis_client_sdk,
@@ -212,10 +209,7 @@ async def test_semaphore_acquire_release_basic(
212209
)
213210

214211
# so does release again
215-
with pytest.raises(
216-
SemaphoreNotAcquiredError,
217-
match=f"Semaphore '{semaphore_name}' was not acquired by this instance",
218-
):
212+
with pytest.raises(SemaphoreNotAcquiredError):
219213
await semaphore.release()
220214
await _assert_semaphore_redis_state(
221215
redis_client_sdk,
@@ -258,10 +252,7 @@ async def test_semaphore_acquire_release_with_ttl_expiry(
258252
)
259253

260254
# TTL expired, reacquire should fail
261-
with pytest.raises(
262-
SemaphoreLostError,
263-
match=f"Semaphore '{semaphore_name}' was lost by this instance",
264-
):
255+
with pytest.raises(SemaphoreLostError):
265256
await semaphore.reacquire()
266257
await _assert_semaphore_redis_state(
267258
redis_client_sdk,
@@ -271,10 +262,17 @@ async def test_semaphore_acquire_release_with_ttl_expiry(
271262
expected_expired=True,
272263
)
273264
# and release should also fail
274-
with pytest.raises(
275-
SemaphoreLostError,
276-
match=f"Semaphore '{semaphore_name}' was lost by this instance",
277-
):
265+
with pytest.raises(SemaphoreLostError):
266+
await semaphore.release()
267+
await _assert_semaphore_redis_state(
268+
redis_client_sdk,
269+
semaphore,
270+
expected_count=0,
271+
expected_free_tokens=semaphore_capacity,
272+
)
273+
274+
# and release again should also fail with different error
275+
with pytest.raises(SemaphoreNotAcquiredError):
278276
await semaphore.release()
279277
await _assert_semaphore_redis_state(
280278
redis_client_sdk,

0 commit comments

Comments
 (0)