package tests import ( "os" "os/exec" "path/filepath" "testing" "time" "hth/internal/testutil" ) func pythonWithPytest(t *testing.T) string { t.Helper() cands := []string{ filepath.Join(testutil.HostRoot(t), ".venv-sdk", "bin", "python"), "/opt/python-3.12/bin/python3.12", "python3.12", "python3.11", "/usr/local/bin/python3.11", "python3.13", "python3", } for _, py := range cands { if filepath.IsAbs(py) { if _, err := os.Stat(py); err != nil { continue } } else if _, err := exec.LookPath(py); err != nil { continue } if err := exec.Command(py, "-m", "pytest", "--version").Run(); err == nil { return py } } t.Skip("pytest not available") return "" } func TestPythonSDKLiveUDS(t *testing.T) { py := pythonWithPytest(t) _, obs, ctl := startMockApp(t) cmd := exec.Command(py, "-m", "pytest", "-q", filepath.Join(testutil.HostRoot(t), "sdk", "python", "tests", "test_live_uds.py")) cmd.Dir = filepath.Join(testutil.HostRoot(t), "sdk", "python") cmd.Env = append(os.Environ(), "HTH_OBSERVE_SOCK="+obs, "HTH_CONTROL_SOCK="+ctl, "PYTHONPATH="+filepath.Join(testutil.HostRoot(t), "sdk", "python"), ) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr done := make(chan error, 1) go func() { done <- cmd.Run() }() select { case err := <-done: if err != nil { t.Fatal(err) } case <-time.After(30 * time.Second): _ = cmd.Process.Kill() t.Fatal("python live test timeout") } }