From cab41c8a759f285f4bd171b339aaa14766345d00 Mon Sep 17 00:00:00 2001 From: mvalentsev Date: Tue, 12 May 2026 05:57:18 +0500 Subject: [PATCH] test(hooks): use hook.get("type") for graceful assert message A direct ``hook["type"]`` subscript raised ``KeyError`` before the assert evaluated when the ``"type"`` key was missing, so the diagnostic message naming the event and the unexpected value was never shown. ``hook.get("type")`` lets the assert fail gracefully with the intended feedback. --- tests/test_claude_plugin_hook_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_claude_plugin_hook_config.py b/tests/test_claude_plugin_hook_config.py index 25b8678..6c33054 100644 --- a/tests/test_claude_plugin_hook_config.py +++ b/tests/test_claude_plugin_hook_config.py @@ -59,7 +59,7 @@ def test_plugin_hook_timeout_within_bounds(hook_config: dict, event: str) -> Non ), f"{event} entry expected exactly one hook command, found {len(sub_hooks)}" for hook in sub_hooks: assert ( - hook["type"] == "command" + hook.get("type") == "command" ), f"unexpected hook type for {event}: {hook.get('type')!r}" assert "timeout" in hook, f"{event} hook missing 'timeout' key" timeout = hook["timeout"]