TestOutputFormatDeprecation Class — anthropic-sdk-python Architecture
Architecture documentation for the TestOutputFormatDeprecation class in test_output_format_conversion.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 16f322e6_6eea_a8f2_83a5_9fdca56649bd["TestOutputFormatDeprecation"] 17ce5647_6f06_0676_a4a5_e378a3f57cb1["BaseModel"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|extends| 17ce5647_6f06_0676_a4a5_e378a3f57cb1 95c8f4d2_e4af_bb89_0668_a558e9dbecb5["test_output_format_conversion.py"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|defined in| 95c8f4d2_e4af_bb89_0668_a558e9dbecb5 837cb6e7_6164_aabe_88be_5a74bf3b7e75["test_create_emits_deprecation_warning()"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|method| 837cb6e7_6164_aabe_88be_5a74bf3b7e75 3f797b55_92a4_87aa_a7f9_5c348c904f2e["test_parse_emits_deprecation_warning()"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|method| 3f797b55_92a4_87aa_a7f9_5c348c904f2e dc47fb0a_6e17_4eab_edc9_87de5fba3460["test_stream_emits_deprecation_warning()"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|method| dc47fb0a_6e17_4eab_edc9_87de5fba3460 51f83926_e8cf_a49f_77ef_77df83ecdc24["test_count_tokens_emits_deprecation_warning()"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|method| 51f83926_e8cf_a49f_77ef_77df83ecdc24 2ba6d02b_6ab9_b205_7762_d98482434c2f["test_no_warning_when_output_format_not_provided()"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|method| 2ba6d02b_6ab9_b205_7762_d98482434c2f 8be1e00e_92bd_882b_dbd0_d5249dd09d1b["test_no_warning_when_using_output_config()"] 16f322e6_6eea_a8f2_83a5_9fdca56649bd -->|method| 8be1e00e_92bd_882b_dbd0_d5249dd09d1b
Relationship Graph
Source Code
tests/api_resources/beta/test_output_format_conversion.py lines 161–309
class TestOutputFormatDeprecation:
"""Test that output_format parameter emits deprecation warnings."""
def test_create_emits_deprecation_warning(self, client: Anthropic, respx_mock: MockRouter) -> None:
"""Verify .create() emits DeprecationWarning when output_format is used."""
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": "test", "type": "text"}],
"stop_reason": "end_turn",
"usage": {"input_tokens": 10, "output_tokens": 20},
},
)
)
with pytest.warns(DeprecationWarning, match="output_format.*deprecated.*output_config.format"):
client.beta.messages.create(
max_tokens=1024,
messages=[{"role": "user", "content": "Test"}],
model="claude-sonnet-4-5",
output_format={"type": "json_schema", "schema": {"type": "object"}},
)
@pytest.mark.skipif(_compat.PYDANTIC_V1, reason="parse with Pydantic models requires Pydantic v2")
def test_parse_emits_deprecation_warning(self, client: Anthropic, respx_mock: MockRouter) -> None:
"""Verify .parse() emits DeprecationWarning when output_format is used."""
class SimpleModel(BaseModel):
value: str
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": "test"}', "type": "text"}],
"stop_reason": "end_turn",
"usage": {"input_tokens": 10, "output_tokens": 20},
},
)
)
with pytest.warns(DeprecationWarning, match="output_format.*deprecated.*output_config.format"):
client.beta.messages.parse(
max_tokens=1024,
messages=[{"role": "user", "content": "Test"}],
model="claude-sonnet-4-5",
output_format=SimpleModel,
)
def test_stream_emits_deprecation_warning(self, client: Anthropic, respx_mock: MockRouter) -> None:
"""Verify .stream() emits DeprecationWarning when output_format is used."""
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": "test", "type": "text"}],
"stop_reason": "end_turn",
"usage": {"input_tokens": 10, "output_tokens": 20},
},
)
)
with pytest.warns(DeprecationWarning, match="output_format.*deprecated.*output_config.format"):
with client.beta.messages.stream(
max_tokens=1024,
messages=[{"role": "user", "content": "Test"}],
model="claude-sonnet-4-5",
output_format={"type": "json_schema", "schema": {"type": "string"}},
Extends
Source
Frequently Asked Questions
What is the TestOutputFormatDeprecation class?
TestOutputFormatDeprecation is a class in the anthropic-sdk-python codebase, defined in tests/api_resources/beta/test_output_format_conversion.py.
Where is TestOutputFormatDeprecation defined?
TestOutputFormatDeprecation is defined in tests/api_resources/beta/test_output_format_conversion.py at line 161.
What does TestOutputFormatDeprecation extend?
TestOutputFormatDeprecation extends BaseModel.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free