test: keep the CLI's saved selections out of the user's home (#1395)

- every test saves and reads CLI selections under its own tmp_path
This commit is contained in:
Yijia-Xiao
2026-09-24 18:45:44 +00:00
parent 47ac1f2d1e
commit f4269bf193
3 changed files with 23 additions and 11 deletions
+6
View File
@@ -45,6 +45,12 @@ def _no_network(request, monkeypatch):
monkeypatch.setattr(socket.socket, "connect_ex", refuse)
@pytest.fixture(autouse=True)
def _own_cli_prefs(tmp_path, monkeypatch):
"""The CLI keeps the last run's selections in the user's home; tests keep theirs apart."""
monkeypatch.setattr("cli.prefs._PREFS_PATH", tmp_path / "cli_prefs.json")
_API_KEY_ENV_VARS = (
"OPENAI_API_KEY",
"GOOGLE_API_KEY",