From 8bc9dfdc802e2a2a00f678c8e7e3e2e1f1b190b3 Mon Sep 17 00:00:00 2001 From: Q00 Date: Mon, 25 May 2026 19:33:27 +0900 Subject: [PATCH] test(canonical): assert live error formatting Add a hermetic unit assertion for the canonical live-run MCP error message using the real Result API. This addresses the low-priority follow-up from PR #1218 around failure formatting coverage.\n\nServices: shared\nAffected files:\n- tests/canonical/test_canonical.py --- tests/canonical/test_canonical.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/canonical/test_canonical.py b/tests/canonical/test_canonical.py index 169f1f677..8f4732aa6 100644 --- a/tests/canonical/test_canonical.py +++ b/tests/canonical/test_canonical.py @@ -22,6 +22,8 @@ import pytest +from ouroboros.core.types import Result + from .conftest import CanonicalScenario @@ -268,3 +270,31 @@ async def test_scenario_live_run_or_skip( f"CANONICAL {scenario.slug}: status={tool_result.meta['status']} " f"phase={tool_result.meta.get('phase')} completion_mode={scenario.completion_mode}" ) + + +@pytest.mark.asyncio +async def test_live_run_formats_mcp_error_result( + scenario: CanonicalScenario, + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, +) -> None: + """Pin the live-run failure message against the real Result API.""" + + async def fake_invoke(selected: CanonicalScenario, workdir: Path) -> Result[object, str]: + return Result.err(f"{selected.slug} handler unavailable at {workdir.name}") + + monkeypatch.setattr( + "tests.canonical.test_canonical._invoke_ouroboros_auto", + fake_invoke, + ) + + with pytest.raises(AssertionError) as exc_info: + await test_scenario_live_run_or_skip( + scenario=scenario, + live_run_enabled=True, + tmp_path=tmp_path, + ) + + message = str(exc_info.value) + assert f"{scenario.slug}: ouroboros_auto returned MCP error" in message + assert f"{scenario.slug} handler unavailable" in message