@@ -5584,18 +5584,18 @@ class _UnfinishedHandlersOnWorkflowTerminationTest:
5584
5584
async def test_warning_is_issued_on_exit_with_unfinished_handler (
5585
5585
self ,
5586
5586
):
5587
- warning_emitted = await self ._run_workflow_and_get_warning ()
5587
+ warnings_emitted = await self ._run_workflow_and_get_warning ()
5588
5588
if self .workflow_termination_type == "-cancellation-" :
5589
5589
# All paths through this test for which the workflow is cancelled result
5590
5590
# in the warning being emitted.
5591
- assert warning_emitted
5591
+ assert warnings_emitted == 1
5592
5592
else :
5593
5593
# Otherwise, the warning is emitted iff the workflow does not wait for handlers to finish.
5594
- assert warning_emitted == (
5595
- self .handler_waiting == "-no-wait-all-handlers-finish-"
5594
+ assert warnings_emitted == (
5595
+ 1 if self .handler_waiting == "-no-wait-all-handlers-finish-" else 0
5596
5596
)
5597
5597
5598
- async def _run_workflow_and_get_warning (self ) -> bool :
5598
+ async def _run_workflow_and_get_warning (self ) -> int :
5599
5599
workflow_id = f"wf-{ uuid .uuid4 ()} "
5600
5600
update_id = "update-id"
5601
5601
task_queue = "tq"
@@ -5688,9 +5688,10 @@ async def _run_workflow_and_get_warning(self) -> bool:
5688
5688
== "Deliberately failing post-ContinueAsNew run"
5689
5689
)
5690
5690
5691
- unfinished_handler_warning_emitted = any (
5692
- issubclass ( w . category , self . _unfinished_handler_warning_cls )
5691
+ unfinished_handler_warning_emitted = sum (
5692
+ 1
5693
5693
for w in warnings
5694
+ if issubclass (w .category , self ._unfinished_handler_warning_cls )
5694
5695
)
5695
5696
return unfinished_handler_warning_emitted
5696
5697
0 commit comments