"""Opt-in E2E: real Pi CLI + real LLM + real workbook through product APIs.""" from __future__ import annotations import os import pytest from tests.e2e.pi_real_workbook_e2e import REPRO_COMMAND, RealPiWorkbookE2E pytestmark = pytest.mark.skipif( os.environ.get("APS_REAL_PI_E2E") != "1", reason=( "Real Pi/LLM E2E is opt-in only. Set APS_REAL_PI_E2E=1 and " "ROUND87_SOURCE to run it; the default pytest command never invokes a real model." ), ) def test_real_pi_real_llm_real_workbook_product_chat_e2e(monkeypatch): """Run the isolated product flow and preserve reproducible artifacts on failure.""" flow = RealPiWorkbookE2E(monkeypatch) try: summary = flow.run() except BaseException: print("\n[real-pi-e2e] FAILED") print(f"[real-pi-e2e] artifacts: {flow.artifact_root}") print(f"[real-pi-e2e] reproduce: {REPRO_COMMAND.replace('', str(flow.artifact_base))}") raise print("\n[real-pi-e2e] PASSED") print(f"[real-pi-e2e] artifacts: {summary['artifactRoot']}") print(f"[real-pi-e2e] pi runs: {len(summary['piRuns'])}") print(f"[real-pi-e2e] source unchanged: {summary['source']['unchanged']}")