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 <noreply@anthropic.com>
This commit is contained in:
Stephen Sennett 2026-09-10 02:53:02 +10:00
parent b5dfba190c
commit 579e0d37f3
2 changed files with 5 additions and 4 deletions

View file

@ -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)

View file

@ -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)