Skip to content

Commit a9600e3

Browse files
committed
Strengthen test assertion (count instead of presence)
1 parent 87f540e commit a9600e3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/worker/test_workflow.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -5584,18 +5584,18 @@ class _UnfinishedHandlersOnWorkflowTerminationTest:
55845584
async def test_warning_is_issued_on_exit_with_unfinished_handler(
55855585
self,
55865586
):
5587-
warning_emitted = await self._run_workflow_and_get_warning()
5587+
warnings_emitted = await self._run_workflow_and_get_warning()
55885588
if self.workflow_termination_type == "-cancellation-":
55895589
# All paths through this test for which the workflow is cancelled result
55905590
# in the warning being emitted.
5591-
assert warning_emitted
5591+
assert warnings_emitted == 1
55925592
else:
55935593
# 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
55965596
)
55975597

5598-
async def _run_workflow_and_get_warning(self) -> bool:
5598+
async def _run_workflow_and_get_warning(self) -> int:
55995599
workflow_id = f"wf-{uuid.uuid4()}"
56005600
update_id = "update-id"
56015601
task_queue = "tq"
@@ -5688,9 +5688,10 @@ async def _run_workflow_and_get_warning(self) -> bool:
56885688
== "Deliberately failing post-ContinueAsNew run"
56895689
)
56905690

5691-
unfinished_handler_warning_emitted = any(
5692-
issubclass(w.category, self._unfinished_handler_warning_cls)
5691+
unfinished_handler_warning_emitted = sum(
5692+
1
56935693
for w in warnings
5694+
if issubclass(w.category, self._unfinished_handler_warning_cls)
56945695
)
56955696
return unfinished_handler_warning_emitted
56965697

0 commit comments

Comments
 (0)