From 9fbdba17ca954ea3e632fef1e79e70c6620d670f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Apr 2026 23:09:23 +0000 Subject: [PATCH] test: isolate embedding device env override tests Agent-Logs-Url: https://github.com/MemPalace/mempalace/sessions/3213a67a-6871-4bb2-9ae0-23fa11001a22 Co-authored-by: igorls <4753812+igorls@users.noreply.github.com> --- tests/test_config.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index c2b537a..8d9753b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -20,12 +20,14 @@ def test_config_from_file(): assert cfg.palace_path == "/custom/palace" -def test_embedding_device_defaults_to_auto(): +def test_embedding_device_defaults_to_auto(monkeypatch): + monkeypatch.delenv("MEMPALACE_EMBEDDING_DEVICE", raising=False) cfg = MempalaceConfig(config_dir=tempfile.mkdtemp()) assert cfg.embedding_device == "auto" -def test_embedding_device_from_config_is_normalized(tmp_path): +def test_embedding_device_from_config_is_normalized(tmp_path, monkeypatch): + monkeypatch.delenv("MEMPALACE_EMBEDDING_DEVICE", raising=False) with open(tmp_path / "config.json", "w") as f: json.dump({"embedding_device": " CUDA "}, f) @@ -33,15 +35,13 @@ def test_embedding_device_from_config_is_normalized(tmp_path): assert cfg.embedding_device == "cuda" -def test_embedding_device_env_overrides_config(tmp_path): +def test_embedding_device_env_overrides_config(tmp_path, monkeypatch): with open(tmp_path / "config.json", "w") as f: json.dump({"embedding_device": "cpu"}, f) - os.environ["MEMPALACE_EMBEDDING_DEVICE"] = " CoreML " - try: - cfg = MempalaceConfig(config_dir=str(tmp_path)) - assert cfg.embedding_device == "coreml" - finally: - del os.environ["MEMPALACE_EMBEDDING_DEVICE"] + monkeypatch.setenv("MEMPALACE_EMBEDDING_DEVICE", " CoreML ") + + cfg = MempalaceConfig(config_dir=str(tmp_path)) + assert cfg.embedding_device == "coreml" def test_env_override():