test(mcp): fix Windows subprocess env in KG lazy-init test

Passing a stripped env dict without SYSTEMROOT/WINDIR breaks Python
bootstrap on Windows (_Py_HashRandomization_Init). Inherit the parent
env and strip MEMPAL* vars instead, then override HOME/USERPROFILE to
the tmp dir.
This commit is contained in:
mvalentsev
2026-04-24 13:03:12 +05:00
parent c69a622a18
commit 84f9726a39
+4 -6
View File
@@ -1160,14 +1160,12 @@ class TestKGLazyCache:
import sys
kg_file = tmp_path / ".mempalace" / "knowledge_graph.sqlite3"
env = {k: v for k, v in os.environ.items() if not k.startswith("MEMPAL")}
env["HOME"] = str(tmp_path)
env["USERPROFILE"] = str(tmp_path)
result = subprocess.run(
[sys.executable, "-c", "import mempalace.mcp_server"],
env={
"HOME": str(tmp_path),
"USERPROFILE": str(tmp_path),
"PATH": os.environ.get("PATH", ""),
"PYTHONPATH": os.environ.get("PYTHONPATH", ""),
},
env=env,
capture_output=True,
text=True,
timeout=30,