The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
tests(vcr): emit verbose verdicts to un-redirected stderr
mateo-berric05c865a1c42
diff --git a/tests/_vcr_redis_persister.py b/tests/_vcr_redis_persister.pyindex 3483f9d2533..03cec23f4d3 100644--- a/tests/_vcr_redis_persister.py+++ b/tests/_vcr_redis_persister.py@@ -216,6 +216,30 @@ def vcr_verbose_enabled() -> bool:return os.environ.get(VCR_VERBOSE_ENV) == "1"+def emit_vcr_verbose_line(line: str) -> None:+ """Write a one-line VCR verdict to the un-redirected stderr.++ Pytest's stdout/stderr capture would otherwise hide this output (and+ only surface it as 'Captured stdout teardown' on failing tests). Under+ xdist each worker has its own stderr; CircleCI aggregates them. Writing+ to ``sys.__stderr__`` bypasses pytest's capture entirely so the line+ reaches the live CI log alongside the per-test PASSED/FAILED markers.+ """+ import sys++ try:+ stream = sys.__stderr__+ if stream is not None:+ stream.write(line + "\n")+ stream.flush()+ return+ except Exception: # pragma: no cover - last-ditch fallback+ pass+ # If __stderr__ isn't writable for some reason, fall back to the+ # captured stderr — better than swallowing.+ print(line, file=sys.stderr)++def format_vcr_verdict(cassette: Any) -> str:"""Build a one-line hit/miss verdict for a vcrpy Cassette.diff --git a/tests/llm_responses_api_testing/conftest.py b/tests/llm_responses_api_testing/conftest.pyindex bf74f2c6a8d..3d405decaa2 100644--- a/tests/llm_responses_api_testing/conftest.py+++ b/tests/llm_responses_api_testing/conftest.py@@ -14,6 +14,7 @@ sys.path.insert(import litellm # noqa: E402from tests._vcr_redis_persister import ( # noqa: E402+ emit_vcr_verbose_line,filter_non_2xx_response,format_vcr_verdict,make_redis_persister,@@ -140,12 +141,7 @@ def _vcr_outcome_gate(request, vcr):if not vcr_verbose_enabled():returnverdict = format_vcr_verdict(cassette)- reporter = request.config.pluginmanager.get_plugin("terminalreporter")- line = f"{verdict} :: {request.node.nodeid}"- if reporter is not None:- reporter.write_line(line)- else: # pragma: no cover - reporter is always present in normal runs- print(line)+ emit_vcr_verbose_line(f"{verdict} :: {request.node.nodeid}")@pytest.fixture(scope="session")diff --git a/tests/llm_translation/conftest.py b/tests/llm_translation/conftest.pyindex afd48bb6742..f17ab32a625 100644--- a/tests/llm_translation/conftest.py+++ b/tests/llm_translation/conftest.py@@ -19,6 +19,7 @@ sys.path.insert(import litellm # noqa: E402from tests._vcr_redis_persister import ( # noqa: E402+ emit_vcr_verbose_line,filter_non_2xx_response,format_vcr_verdict,make_redis_persister,@@ -194,12 +195,7 @@ def _vcr_outcome_gate(request, vcr):if not vcr_verbose_enabled():returnverdict = format_vcr_verdict(cassette)- reporter = request.config.pluginmanager.get_plugin("terminalreporter")- line = f"{verdict} :: {request.node.nodeid}"- if reporter is not None:- reporter.write_line(line)- else: # pragma: no cover - reporter is always present in normal runs- print(line)+ emit_vcr_verbose_line(f"{verdict} :: {request.node.nodeid}")# ---------------------------------------------------------------------------