test: use tmp_path for embedding device config 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>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-24 23:08:26 +00:00
committed by GitHub
parent fbd0904799
commit 25c885ae0b
+6 -8
View File
@@ -25,22 +25,20 @@ def test_embedding_device_defaults_to_auto():
assert cfg.embedding_device == "auto"
def test_embedding_device_from_config_is_normalized():
tmpdir = tempfile.mkdtemp()
with open(os.path.join(tmpdir, "config.json"), "w") as f:
def test_embedding_device_from_config_is_normalized(tmp_path):
with open(tmp_path / "config.json", "w") as f:
json.dump({"embedding_device": " CUDA "}, f)
cfg = MempalaceConfig(config_dir=tmpdir)
cfg = MempalaceConfig(config_dir=str(tmp_path))
assert cfg.embedding_device == "cuda"
def test_embedding_device_env_overrides_config():
tmpdir = tempfile.mkdtemp()
with open(os.path.join(tmpdir, "config.json"), "w") as f:
def test_embedding_device_env_overrides_config(tmp_path):
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=tmpdir)
cfg = MempalaceConfig(config_dir=str(tmp_path))
assert cfg.embedding_device == "coreml"
finally:
del os.environ["MEMPALACE_EMBEDDING_DEVICE"]