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:
@@ -1160,14 +1160,12 @@ class TestKGLazyCache:
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
kg_file = tmp_path / ".mempalace" / "knowledge_graph.sqlite3"
|
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(
|
result = subprocess.run(
|
||||||
[sys.executable, "-c", "import mempalace.mcp_server"],
|
[sys.executable, "-c", "import mempalace.mcp_server"],
|
||||||
env={
|
env=env,
|
||||||
"HOME": str(tmp_path),
|
|
||||||
"USERPROFILE": str(tmp_path),
|
|
||||||
"PATH": os.environ.get("PATH", ""),
|
|
||||||
"PYTHONPATH": os.environ.get("PYTHONPATH", ""),
|
|
||||||
},
|
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
timeout=30,
|
timeout=30,
|
||||||
|
|||||||
Reference in New Issue
Block a user