File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
packages/service-library/tests/redis Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -281,10 +281,16 @@ async def delayed_release() -> None:
281281 await semaphore2 .release ()
282282
283283
284+ @pytest .mark .parametrize (
285+ "exception" ,
286+ [RuntimeError , asyncio .CancelledError ],
287+ ids = str ,
288+ )
284289async def test_semaphore_context_manager_with_exception (
285290 redis_client_sdk : RedisClientSDK ,
286291 semaphore_name : str ,
287292 semaphore_capacity : int ,
293+ exception : type [Exception | asyncio .CancelledError ],
288294):
289295 captured_semaphore : DistributedSemaphore | None = None
290296
@@ -296,10 +302,9 @@ async def _raising_context():
296302 ) as sem :
297303 nonlocal captured_semaphore
298304 captured_semaphore = sem
299- msg = "Test exception"
300- raise RuntimeError (msg )
305+ raise exception ("Test" )
301306
302- with pytest .raises (RuntimeError , match = "Test exception " ):
307+ with pytest .raises (exception , match = "Test" ):
303308 await _raising_context ()
304309
305310 # Should be released even after exception
You can’t perform that action at this time.
0 commit comments