_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).
7.9 KiB
7.9 KiB