test_parse_preserves_existing_betas() — anthropic-sdk-python Function Reference
Architecture documentation for the test_parse_preserves_existing_betas() function in test_output_format_conversion.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 96b04993_07b0_0234_0ee9_323dc41eebc8["test_parse_preserves_existing_betas()"] 91bf20e2_262e_34e5_0c93_658022fb45df["TestStructuredOutputsBetaHeader"] 96b04993_07b0_0234_0ee9_323dc41eebc8 -->|defined in| 91bf20e2_262e_34e5_0c93_658022fb45df style 96b04993_07b0_0234_0ee9_323dc41eebc8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/api_resources/beta/test_output_format_conversion.py lines 419–453
def test_parse_preserves_existing_betas(self, client: Anthropic, respx_mock: MockRouter) -> None:
"""Verify .parse() preserves other beta headers when adding structured-outputs."""
class DataModel(BaseModel):
value: int
respx_mock.post("/v1/messages?beta=true").mock(
return_value=httpx.Response(
200,
json={
"id": "msg_123",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-5",
"content": [{"text": '{"value": 42}', "type": "text"}],
"stop_reason": "end_turn",
"usage": {"input_tokens": 10, "output_tokens": 20},
},
)
)
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
client.beta.messages.parse(
max_tokens=1024,
messages=[{"role": "user", "content": "Test"}],
model="claude-sonnet-4-5",
output_format=DataModel,
betas=["some-other-beta-feature"],
)
request = respx_mock.calls.last.request
beta_header = request.headers["anthropic-beta"]
assert "structured-outputs-2025-12-15" in beta_header
assert "some-other-beta-feature" in beta_header
Domain
Subdomains
Source
Frequently Asked Questions
What does test_parse_preserves_existing_betas() do?
test_parse_preserves_existing_betas() is a function in the anthropic-sdk-python codebase, defined in tests/api_resources/beta/test_output_format_conversion.py.
Where is test_parse_preserves_existing_betas() defined?
test_parse_preserves_existing_betas() is defined in tests/api_resources/beta/test_output_format_conversion.py at line 419.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free