Skip to content

"Vibe-Trading: Your Personal Trading Agent"

test(factors): fall back to a real copy when the src alias symlink is refused

cxzyyf9b66849505e
diff --git a/agent/tests/factors/test_registry.py b/agent/tests/factors/test_registry.py
index fe8ffd088..26b70114f 100644
--- a/agent/tests/factors/test_registry.py
+++ b/agent/tests/factors/test_registry.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import shutil
import sys
import textwrap
from pathlib import Path
@@ -88,7 +89,16 @@ def mini_zoo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
# monkey-patching sys.path to include tmp_path, then creating an `src`
# alias that points to `factors/`-as-`src.factors`.
src_alias = tmp_path / "src"
- src_alias.symlink_to(tmp_path)
+ try:
+ src_alias.symlink_to(tmp_path)
+ except OSError:
+ # Symlinks need privileges on Windows (OSError 1314 even in an
+ # otherwise healthy environment), so fall back to a real copy —
+ # the same fallback the sandbox home in `core/runner.py` uses. The
+ # alias only has to present the same tree at `src/factors/...`, and
+ # a registry pointed at a custom zoo_root loads modules by file
+ # path, so the copy never has to track later fixture writes.
+ shutil.copytree(tmp_path / "factors", src_alias / "factors")
monkeypatch.syspath_prepend(str(tmp_path))
# Reset any cached modules from previous test
for mod_name in list(sys.modules):
@@ -107,6 +117,32 @@ def _panel(n: int = 5) -> dict[str, pd.DataFrame]:
}
+def _deny_symlink(monkeypatch: pytest.MonkeyPatch) -> None:
+ def _raise(*args, **kwargs):
+ raise OSError(1314, "A required privilege is not held by the client")
+
+ monkeypatch.setattr(Path, "symlink_to", _raise)
+
+
+def test_mini_zoo_copy_fallback_when_symlink_privileges_missing(
+ _deny_symlink: None, mini_zoo: Path
+) -> None:
+ """The copy fallback keeps the suite alive on symlink-less hosts.
+
+ Windows without symlink privilege refuses the alias's symlink with
+ OSError 1314 even in an otherwise healthy environment; the fixture must
+ still deliver a working zoo tree. Mirrors the parallel pin on the
+ sandbox home's copy fallback in ``test_runner_env.py``.
+ """
+ src_alias = mini_zoo.parents[1] / "src"
+ assert src_alias.is_dir() and not src_alias.is_symlink()
+ reg = Registry(zoo_root=mini_zoo)
+ assert reg.health()["loaded"] == 4
+ out = reg.compute("fakezoo_001", _panel())
+ assert out.shape == (5, 2)
+
+
# ---------------- AST extraction ----------------