Skip to content

Personal AI, On Personal Devices

Python

fix(tests): fix three Windows-only test failures (#785) (#813)

havolline152bf3362be19
diff --git a/tests/evals/comparison/test_openclaw_runner_contract.py b/tests/evals/comparison/test_openclaw_runner_contract.py
index 0db4f5c1..96cc5200 100644
--- a/tests/evals/comparison/test_openclaw_runner_contract.py
+++ b/tests/evals/comparison/test_openclaw_runner_contract.py
@@ -3,6 +3,7 @@
from __future__ import annotations
import json
+import os
import shutil
import subprocess
from pathlib import Path
@@ -35,9 +36,17 @@ def test_openclaw_runner_parses_real_agent_json_shape(tmp_path: Path) -> None:
/ "src/openjarvis/evals/backends/external/_runners/openclaw_runner.mjs"
)
out_json = tmp_path / "out.json"
+ # subprocess.run's `env` REPLACES the environment rather than merging
+ # it, so passing just these two keys wiped everything Node needs to
+ # even start on Windows (TEMP/TMP/SystemRoot/PATH) -- os.tmpdir()
+ # falls back to the literal string 'undefined' when those are unset,
+ # and mkdtemp then fails with ENOENT (#785). Inherit the parent
+ # environment and layer the test-specific overrides on top.
env = {
+ **os.environ,
"OPENCLAW_PATH": str(tmp_path),
"HOME": str(tmp_path / "home"),
+ "USERPROFILE": str(tmp_path / "home"),
}
result = subprocess.run(
[
diff --git a/tests/evals/core/test_config_split_parsing.py b/tests/evals/core/test_config_split_parsing.py
index c731ac17..be1739fa 100644
--- a/tests/evals/core/test_config_split_parsing.py
+++ b/tests/evals/core/test_config_split_parsing.py
@@ -15,7 +15,7 @@ def _write_config(tmp_path: Path, split_value: str | None) -> Path:
name = "split-parse-test"
[run]
-output_dir = "{tmp_path / "out"}"
+output_dir = "{(tmp_path / "out").as_posix()}"
seed = 42
[[models]]
diff --git a/tests/learning/test_trial_runner.py b/tests/learning/test_trial_runner.py
index 93d73596..fbe95874 100644
--- a/tests/learning/test_trial_runner.py
+++ b/tests/learning/test_trial_runner.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+from pathlib import Path
from unittest.mock import MagicMock, patch
from openjarvis.evals.core.types import RunConfig, RunSummary
@@ -137,7 +138,9 @@ class TestBuildRunConfig:
cfg = runner._build_run_config(trial, recipe)
assert "trial-abc" in cfg.output_path
- assert cfg.output_path.startswith("out/")
+ # Path(...) / "..." legitimately produces backslashes on Windows,
+ # so compare path components rather than a hard-coded "out/".
+ assert Path(cfg.output_path).parts[0] == "out"
def test_default_model_fallback(self) -> None:
runner = TrialRunner(benchmark="supergpqa")