fix(tests): isolate tests from user ~/.hermes/ config and SOUL.md
_make_cli() now patches CLI_CONFIG with clean defaults so test_cli_init tests don't depend on the developer's local config.yaml. test_empty_dir_returns_empty now mocks Path.home() so it doesn't pick up a global SOUL.md. Credit to teyrebaz33 for identifying and fixing these in PR #557. Fixes #555.
This commit is contained in:
parent
6cd3bc6640
commit
2a68099675
2 changed files with 19 additions and 2 deletions
|
|
@ -172,7 +172,11 @@ class TestBuildSkillsSystemPrompt:
|
||||||
|
|
||||||
class TestBuildContextFilesPrompt:
|
class TestBuildContextFilesPrompt:
|
||||||
def test_empty_dir_returns_empty(self, tmp_path):
|
def test_empty_dir_returns_empty(self, tmp_path):
|
||||||
result = build_context_files_prompt(cwd=str(tmp_path))
|
from unittest.mock import patch
|
||||||
|
fake_home = tmp_path / "fake_home"
|
||||||
|
fake_home.mkdir()
|
||||||
|
with patch("pathlib.Path.home", return_value=fake_home):
|
||||||
|
result = build_context_files_prompt(cwd=str(tmp_path))
|
||||||
assert result == ""
|
assert result == ""
|
||||||
|
|
||||||
def test_loads_agents_md(self, tmp_path):
|
def test_loads_agents_md(self, tmp_path):
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,21 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||||
|
|
||||||
def _make_cli(**kwargs):
|
def _make_cli(**kwargs):
|
||||||
"""Create a HermesCLI instance with minimal mocking."""
|
"""Create a HermesCLI instance with minimal mocking."""
|
||||||
|
import cli as _cli_mod
|
||||||
from cli import HermesCLI
|
from cli import HermesCLI
|
||||||
with patch("cli.get_tool_definitions", return_value=[]):
|
_clean_config = {
|
||||||
|
"model": {
|
||||||
|
"default": "anthropic/claude-opus-4.6",
|
||||||
|
"base_url": "https://openrouter.ai/api/v1",
|
||||||
|
"provider": "auto",
|
||||||
|
},
|
||||||
|
"display": {"compact": False, "tool_progress": "all"},
|
||||||
|
"agent": {},
|
||||||
|
"terminal": {"env_type": "local"},
|
||||||
|
}
|
||||||
|
with patch("cli.get_tool_definitions", return_value=[]), \
|
||||||
|
patch.dict("os.environ", {"LLM_MODEL": ""}, clear=False), \
|
||||||
|
patch.dict(_cli_mod.__dict__, {"CLI_CONFIG": _clean_config}):
|
||||||
return HermesCLI(**kwargs)
|
return HermesCLI(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue