mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-19 03:05:24 -04:00
test: stop test_skill_index_prompt_injection leaking a stub prefs_routes (#4387)
_patch_prefs installs a fake routes.prefs_routes with a bare sys.modules[...] = assignment that is never undone. The stub is an empty ModuleType without _save_for_user, so a later test whose code path runs `from routes.prefs_routes import _save_for_user` (e.g. test_backup_import_skills) fails with ImportError under an unfavorable test order. Install the stub with monkeypatch.setitem instead (the helper already takes monkeypatch and uses it for DATA_DIR) so it is reverted at teardown. Repro: pytest tests/test_skill_index_prompt_injection.py tests/test_backup_import_skills.py (1 failed before, 5 passed after).
This commit is contained in:
@@ -105,7 +105,7 @@ def _patch_prefs(monkeypatch, data_dir):
|
||||
"skills_enabled": True,
|
||||
"auto_approve_skills": True,
|
||||
}
|
||||
sys.modules["routes.prefs_routes"] = fake_prefs
|
||||
monkeypatch.setitem(sys.modules, "routes.prefs_routes", fake_prefs)
|
||||
|
||||
# Bust the base-prompt cache so our test re-reads the skill index.
|
||||
from src import agent_loop
|
||||
|
||||
Reference in New Issue
Block a user