From bf03e15c94ee879d63af40d35c19137905ba0ee4 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:59:19 +0100 Subject: [PATCH] fix checking for non-int args. --- cylc/flow/xtriggers/workflow_state.py | 4 +--- tests/unit/xtriggers/test_workflow_state.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cylc/flow/xtriggers/workflow_state.py b/cylc/flow/xtriggers/workflow_state.py index ca0a96a9aed..a55d5038886 100644 --- a/cylc/flow/xtriggers/workflow_state.py +++ b/cylc/flow/xtriggers/workflow_state.py @@ -114,9 +114,7 @@ def validate(args: Dict[str, Any]): raise WorkflowConfigError( "Full ID needed: workflow//cycle/task[:selector].") - try: - int(args["flow_num"]) - except ValueError: + if not isinstance(args["flow_num"], int): raise WorkflowConfigError("flow_num must be an integer.") diff --git a/tests/unit/xtriggers/test_workflow_state.py b/tests/unit/xtriggers/test_workflow_state.py index cd537a11b7d..95a20f8b8c2 100644 --- a/tests/unit/xtriggers/test_workflow_state.py +++ b/tests/unit/xtriggers/test_workflow_state.py @@ -288,7 +288,7 @@ def test_validate_fail_bad_id(id_): def test_validate_fail_non_int_flow(): """Validate returns ok with valid args.""" - with pytest.raises(ValueError, match='must be an integer'): + with pytest.raises(WorkflowConfigError, match='must be an integer'): validate({ 'workflow_task_id': 'foo//1/bar', 'offset': 'PT1H',