"""Phase 12 site 4: _list_anthropic_models Result migration. Site 4 (L1337): try: anthropic = _require_warmed('anthropic'); ... client.models.list() ... except Exception as exc: raise _classify_anthropic_error(exc) from exc BUG: _classify_anthropic_error(exc) returns ErrorInfo (not an Exception). 'raise ErrorInfo from exc' would fail at runtime. Migrate to Result. """ import sys sys.path.insert(0, ".") def test_phase12_site4_list_anthropic_models_result_exists(): import src.ai_client assert hasattr(src.ai_client, "_list_anthropic_models_result"), \ "_list_anthropic_models_result helper missing" def test_phase12_site4_helper_returns_result(): import src.ai_client import inspect fn = src.ai_client._list_anthropic_models_result sig = inspect.signature(fn) assert "Result" in str(sig.return_annotation), \ f"_list_anthropic_models_result return must be Result, got {sig.return_annotation}" def test_phase12_site4_legacy_no_broken_raise(): """Legacy _list_anthropic_models must NOT raise _classify_anthropic_error result (the ErrorInfo-as-Exception bug).""" import inspect import src.ai_client src_text = inspect.getsource(src.ai_client._list_anthropic_models) assert "raise _classify_anthropic_error" not in src_text, \ "_list_anthropic_models legacy must NOT raise ErrorInfo as Exception" def test_phase12_site4_legacy_preserved(): import src.ai_client assert callable(getattr(src.ai_client, "_list_anthropic_models", None))