Skip to content

The agent that grows with you

test(stash): drop source-text keybinding assertions (banned antipattern)

teknium15686ea43d465
diff --git a/tests/cli/test_prompt_stash_cli.py b/tests/cli/test_prompt_stash_cli.py
index d4ec7120d83..b613fcbd661 100644
--- a/tests/cli/test_prompt_stash_cli.py
+++ b/tests/cli/test_prompt_stash_cli.py
@@ -92,37 +92,22 @@ class TestStashStateInit:
class TestKeybindingRegistration:
- """The Ctrl+S binding must actually be registered on the TUI KeyBindings."""
-
- def test_ctrl_s_source_binding_exists(self):
- """cli.py registers a c-s handler (regression guard for PR #4771).
-
- The original PR's head lost its keybinding during a rebase, shipping
- the panel renderer with no way to reach it. Assert on the source so
- that cannot silently regress again.
- """
- from pathlib import Path
-
- source = Path(
- importlib.import_module("cli").__file__ or ""
- ).read_text(encoding="utf-8")
- assert "@kb.add('c-s'" in source
- assert "def handle_prompt_stash(" in source
-
- def test_panel_navigation_bindings_exist(self):
- from pathlib import Path
-
- source = Path(
- importlib.import_module("cli").__file__ or ""
- ).read_text(encoding="utf-8")
- for handler in (
- "def handle_stash_panel_up(",
- "def handle_stash_panel_down(",
- "def handle_stash_panel_restore(",
- "def handle_stash_panel_delete(",
- "def handle_stash_panel_close(",
- ):
- assert handler in source, f"missing panel handler: {handler}"
+ """Behavioral coverage for the stash keybinding surface.
+
+ NOTE: the Ctrl+S / panel-navigation handlers are registered inside
+ ``HermesCLI.run()``'s local ``KeyBindings`` instance, so they are not
+ importable without launching the TUI. Asserting on cli.py's SOURCE TEXT
+ to prove they exist is the banned change-detector antipattern (root
+ AGENTS.md, "Never read source code in tests"): it passes when the
+ handler exists but is wired wrong, and fails on a correct rename.
+
+ The regression that broke PR #4771 (a rebase silently dropping the
+ keybinding) is instead guarded where the behavior actually lives — the
+ stash state machine below and in test_prompt_stash.py, which every
+ handler delegates to. Extracting run()'s bindings into a standalone
+ registrar would make direct handler tests possible; that refactor is
+ deliberately out of scope for this salvage.
+ """
def test_extension_hook_still_a_noop(self, cli):
"""The stash binding lives in run(), not in the wrapper extension hook."""