MCPcopy Create free account
hub / github.com/IBM/mcp-cli / patch_tool_manager

Function patch_tool_manager

tests/cli/test_run_command.py:114–132  ·  view source on GitHub ↗

Use the new factory pattern for ToolManager injection.

(monkeypatch)

Source from the content-addressed store, hash-verified

112# --------------------------------------------------------------------------- #
113@pytest.fixture(autouse=True)
114def patch_tool_manager(monkeypatch):
115 """Use the new factory pattern for ToolManager injection."""
116 from mcp_cli.run_command import set_tool_manager_factory
117
118 # Set the factory to use DummyToolManager
119 set_tool_manager_factory(DummyToolManager)
120
121 # Also patch the direct import for backward compatibility
122 monkeypatch.setattr(
123 "mcp_cli.tools.manager.ToolManager", DummyToolManager, raising=True
124 )
125
126 # Clean collected list between tests
127 _ALL_TM.clear()
128 yield
129 _ALL_TM.clear()
130
131 # Reset the factory after test
132 set_tool_manager_factory(None)
133
134
135# --------------------------------------------------------------------------- #

Callers

nothing calls this directly

Calls 2

set_tool_manager_factoryFunction · 0.90
clearMethod · 0.45

Tested by

no test coverage detected