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.
This commit is contained in:
mvalentsev
2026-05-13 22:53:48 +05:00
parent 706237476c
commit cab41c8a75
+1 -1
View File
@@ -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"]