Skip to content

The agent that grows with you

test(installer): cover managed Python timeout

fangliquanflq26476a978afd
diff --git a/tests/install_ps1_fake_uv.py b/tests/install_ps1_fake_uv.py
index f6032125965..75bddc8a766 100644
--- a/tests/install_ps1_fake_uv.py
+++ b/tests/install_ps1_fake_uv.py
@@ -24,6 +24,11 @@ public static class FakeUv {
string.Join(" ", args) + Environment.NewLine);
if (args.Length >= 2 && args[0] == "python" && args[1] == "find") {
+ string findDelayMs = Environment.GetEnvironmentVariable(
+ "FAKE_UV_FIND_DELAY_MS");
+ if (!string.IsNullOrEmpty(findDelayMs)) {
+ System.Threading.Thread.Sleep(int.Parse(findDelayMs));
+ }
string stderrBytes = Environment.GetEnvironmentVariable(
"FAKE_UV_FIND_STDERR_BYTES");
if (!string.IsNullOrEmpty(stderrBytes)) {
diff --git a/tests/test_install_ps1_managed_python_provenance.py b/tests/test_install_ps1_managed_python_provenance.py
index 713c4ecef27..5c91721a327 100644
--- a/tests/test_install_ps1_managed_python_provenance.py
+++ b/tests/test_install_ps1_managed_python_provenance.py
@@ -45,7 +45,7 @@ def _run_venv_stage(
capture_output=True,
text=True,
check=False,
- timeout=30,
+ timeout=45,
)
@@ -169,6 +169,29 @@ def test_python_find_drains_large_stderr_without_deadlock(tmp_path: Path) -> Non
assert "Creating virtual environment with Python 3.11" in run.stdout
+def test_python_find_timeout_kills_uv_and_fails_stage(tmp_path: Path) -> None:
+ powershell = shutil.which("powershell")
+ if not powershell:
+ pytest.skip("Windows PowerShell is required")
+
+ hermes_home = tmp_path / "hermes-home"
+ install_dir = tmp_path / "install"
+ uv = hermes_home / "bin" / "uv.exe"
+ uv.parent.mkdir(parents=True)
+ install_dir.mkdir()
+ compile_fake_uv(powershell, uv)
+ env = {
+ **os.environ,
+ "FAKE_UV_LOG": str(tmp_path / "uv.log"),
+ "FAKE_UV_FIND_DELAY_MS": "60000",
+ }
+
+ run = _run_venv_stage(powershell, tmp_path, hermes_home, install_dir, env)
+
+ assert run.returncode != 0
+ assert "uv python find 3.11 timed out after 30000 ms" in (run.stdout + run.stderr)
+
+
def test_venv_failure_fails_stage_and_restores_existing_environment(
tmp_path: Path,
) -> None: