From 579e0d37f3a1a7bdf4688db88ded8c206d053af2 Mon Sep 17 00:00:00 2001 From: Stephen Sennett Date: Thu, 10 Sep 2026 02:53:02 +1000 Subject: [PATCH] test(guardrails): mark the Azure capture lists as callee-filled The request, thread and scope logs the new Azure tests capture are accumulators a callback fills, which the no-mutation convention asks to be marked rather than left bare. Mark all three with a reason, and hand the captured requests back as a Sequence so a test cannot append to the fixture's own log Co-Authored-By: Claude Opus 5 --- .../proxy/guardrails/guardrail_hooks/azure/conftest.py | 5 +++-- .../guardrails/guardrail_hooks/azure/test_azure_base.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/conftest.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/conftest.py index 8e3605137ab..aad05c2017f 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/conftest.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/conftest.py @@ -1,3 +1,4 @@ +from collections.abc import Sequence from typing import Final import httpx @@ -31,9 +32,9 @@ def api_base() -> str: @pytest.fixture -def capturing_handler() -> tuple[AsyncHTTPHandler, list[httpx.Request]]: +def capturing_handler() -> tuple[AsyncHTTPHandler, Sequence[httpx.Request]]: """An HTTP handler answering every Content Safety call, paired with the requests it saw.""" - sent: Final[list[httpx.Request]] = [] + sent: Final[list[httpx.Request]] = [] # mutable-ok: callee-filled request log, handed back read-only def _record(request: httpx.Request) -> httpx.Response: sent.append(request) diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/test_azure_base.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/test_azure_base.py index bb0a1ad4c9a..b461aca6392 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/test_azure_base.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/azure/test_azure_base.py @@ -129,7 +129,7 @@ async def test_token_minting_failure_keeps_credential_detail_out_of_the_error(ap async def test_token_is_minted_off_the_event_loop_thread(api_base, capturing_handler): """Credential sources block: IMDS probes time out and the az CLI credential spawns a subprocess.""" handler, _ = capturing_handler - minting_threads: Final[list[int]] = [] + minting_threads: Final[list[int]] = [] # mutable-ok: callee-filled thread log def _record_thread() -> str: minting_threads.append(threading.get_ident()) @@ -150,7 +150,7 @@ async def test_token_is_minted_off_the_event_loop_thread(api_base, capturing_han def test_default_credential_is_built_once_per_process(monkeypatch): """Rebuilding it per request costs a fresh credential and token round trip on every scan.""" - builds: Final[list[str]] = [] + builds: Final[list[str]] = [] # mutable-ok: callee-filled scope log def _build(azure_scope: str): builds.append(azure_scope)