From 00b8204cf4109ed6ae481ecdfc2dbf99c9a8303e Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 28 May 2026 21:35:19 -0700 Subject: [PATCH] fix: restore side-effect imports in test files (test_kanban_tools, test_command_guards) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous ruff prune commit removed two categories of test-file imports whose value is the side effect of importing them, not their binding: tests/tools/test_kanban_tools.py — 5 sites `import tools.kanban_tools # ensure registered` The import itself runs tools/kanban_tools.py's @registry.register calls; without it, the kanban tool registry is empty and test_kanban_tools_visible_with_env_var asserts {} != {7 kanban tools}. tests/tools/test_command_guards.py — 1 site `import tools.tirith_security # Ensure the module is importable so we can patch it` The comment names the requirement: keep the bare module reference so subsequent mock.patch("tools.tirith_security.") calls find a registered submodule. CI failure: test (5) shard, tests/tools/test_kanban_tools.py:58 AssertionError: expected {kanban_*}, got set() --- tests/tools/test_command_guards.py | 3 +++ tests/tools/test_kanban_tools.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/tests/tools/test_command_guards.py b/tests/tools/test_command_guards.py index fc0d7105aeb..b9be6837971 100644 --- a/tests/tools/test_command_guards.py +++ b/tests/tools/test_command_guards.py @@ -10,9 +10,12 @@ from tools.approval import ( approve_session, check_all_command_guards, is_approved, + set_current_session_key, + reset_current_session_key, ) # Ensure the module is importable so we can patch it +import tools.tirith_security # --------------------------------------------------------------------------- diff --git a/tests/tools/test_kanban_tools.py b/tests/tools/test_kanban_tools.py index efc684ba304..24fa09d8ba2 100644 --- a/tests/tools/test_kanban_tools.py +++ b/tests/tools/test_kanban_tools.py @@ -9,6 +9,7 @@ Verifies: from __future__ import annotations import json +import os import pytest @@ -25,6 +26,7 @@ def test_kanban_tools_hidden_without_env_var(monkeypatch, tmp_path): home.mkdir() monkeypatch.setenv("HERMES_HOME", str(home)) + import tools.kanban_tools # ensure registered from tools.registry import invalidate_check_fn_cache, registry from toolsets import resolve_toolset @@ -44,6 +46,7 @@ def test_kanban_tools_visible_with_env_var(monkeypatch, tmp_path): home.mkdir() monkeypatch.setenv("HERMES_HOME", str(home)) + import tools.kanban_tools # ensure registered from tools.registry import invalidate_check_fn_cache, registry from toolsets import resolve_toolset @@ -67,6 +70,7 @@ def test_kanban_worker_env_overrides_profile_toolset_filter(monkeypatch, tmp_pat home.mkdir() monkeypatch.setenv("HERMES_HOME", str(home)) + import tools.kanban_tools # ensure registered from model_tools import _clear_tool_defs_cache, get_tool_definitions from tools.registry import invalidate_check_fn_cache @@ -96,6 +100,7 @@ def test_worker_with_kanban_toolset_still_hides_board_routing(monkeypatch, tmp_p (home / "config.yaml").write_text("toolsets:\n - kanban\n") monkeypatch.setenv("HERMES_HOME", str(home)) + import tools.kanban_tools # ensure registered from tools.registry import invalidate_check_fn_cache, registry from toolsets import resolve_toolset @@ -120,6 +125,7 @@ def test_kanban_tools_visible_with_toolset_config(monkeypatch, tmp_path): (home / "config.yaml").write_text("toolsets:\n - kanban\n") monkeypatch.setenv("HERMES_HOME", str(home)) + import tools.kanban_tools # ensure registered from tools.registry import invalidate_check_fn_cache, registry from toolsets import resolve_toolset