test_parse_converts_pydantic_to_output_config() — anthropic-sdk-python Function Reference
Architecture documentation for the test_parse_converts_pydantic_to_output_config() function in test_output_format_conversion.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 6de8710b_1294_8b52_2cc4_7f4ae250f21e["test_parse_converts_pydantic_to_output_config()"] ddc92ce5_2097_f12d_1120_7b3ce1aed9e8["TestOutputFormatConversion"] 6de8710b_1294_8b52_2cc4_7f4ae250f21e -->|defined in| ddc92ce5_2097_f12d_1120_7b3ce1aed9e8 style 6de8710b_1294_8b52_2cc4_7f4ae250f21e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/api_resources/beta/test_output_format_conversion.py lines 56–99
def test_parse_converts_pydantic_to_output_config(self, client: Anthropic, respx_mock: MockRouter) -> None:
"""Verify .parse() converts Pydantic models to output_config.format."""
class User(BaseModel):
name: str
age: 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": '{"name": "John", "age": 30}', "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=User,
)
request = respx_mock.calls.last.request
body = json.loads(request.content)
# Should have output_config with format containing the User schema
assert "output_config" in body
assert "format" in body["output_config"]
assert body["output_config"]["format"]["type"] == "json_schema"
assert "properties" in body["output_config"]["format"]["schema"]
assert "name" in body["output_config"]["format"]["schema"]["properties"]
assert "age" in body["output_config"]["format"]["schema"]["properties"]
# Should NOT have output_format in request
assert "output_format" not in body
Domain
Subdomains
Source
Frequently Asked Questions
What does test_parse_converts_pydantic_to_output_config() do?
test_parse_converts_pydantic_to_output_config() is a function in the anthropic-sdk-python codebase, defined in tests/api_resources/beta/test_output_format_conversion.py.
Where is test_parse_converts_pydantic_to_output_config() defined?
test_parse_converts_pydantic_to_output_config() is defined in tests/api_resources/beta/test_output_format_conversion.py at line 56.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free