TestCompletions Class — anthropic-sdk-python Architecture
Architecture documentation for the TestCompletions class in test_completions.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD ab2c04b0_828b_bb78_079a_babbdf3057a0["TestCompletions"] 64848efc_cb91_a8cb_d3ef_c23d6a0890a8["Completion"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|extends| 64848efc_cb91_a8cb_d3ef_c23d6a0890a8 7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87["test_completions.py"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|defined in| 7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 f385cfc0_3ed7_3b72_e6c7_b2eabe18c5c6["test_method_create_overload_1()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| f385cfc0_3ed7_3b72_e6c7_b2eabe18c5c6 0cab0bac_4b3e_160f_157f_71d61deecf81["test_method_create_with_all_params_overload_1()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| 0cab0bac_4b3e_160f_157f_71d61deecf81 4c4bf5b3_df7e_7cf5_3276_79393100eabb["test_raw_response_create_overload_1()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| 4c4bf5b3_df7e_7cf5_3276_79393100eabb 997b4ddb_0516_d807_1323_b6b9dd5db419["test_streaming_response_create_overload_1()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| 997b4ddb_0516_d807_1323_b6b9dd5db419 715c6f82_6c00_a74e_68b0_56d69bddef4c["test_method_create_overload_2()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| 715c6f82_6c00_a74e_68b0_56d69bddef4c cef24728_1b65_0777_3a03_8a557c62d7a8["test_method_create_with_all_params_overload_2()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| cef24728_1b65_0777_3a03_8a557c62d7a8 3cd894ba_8ce5_b351_5a70_5b39fb4986c6["test_raw_response_create_overload_2()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| 3cd894ba_8ce5_b351_5a70_5b39fb4986c6 8253a205_849a_1395_dd62_1967f270745e["test_streaming_response_create_overload_2()"] ab2c04b0_828b_bb78_079a_babbdf3057a0 -->|method| 8253a205_849a_1395_dd62_1967f270745e
Relationship Graph
Source Code
tests/api_resources/test_completions.py lines 17–126
class TestCompletions:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_create_overload_1(self, client: Anthropic) -> None:
completion = client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert_matches_type(Completion, completion, path=["response"])
@parametrize
def test_method_create_with_all_params_overload_1(self, client: Anthropic) -> None:
completion = client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string"],
stream=False,
temperature=1,
top_k=5,
top_p=0.7,
betas=["string"],
)
assert_matches_type(Completion, completion, path=["response"])
@parametrize
def test_raw_response_create_overload_1(self, client: Anthropic) -> None:
response = client.completions.with_raw_response.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
completion = response.parse()
assert_matches_type(Completion, completion, path=["response"])
@parametrize
def test_streaming_response_create_overload_1(self, client: Anthropic) -> None:
with client.completions.with_streaming_response.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
completion = response.parse()
assert_matches_type(Completion, completion, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_method_create_overload_2(self, client: Anthropic) -> None:
completion_stream = client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
)
completion_stream.response.close()
@parametrize
def test_method_create_with_all_params_overload_2(self, client: Anthropic) -> None:
completion_stream = client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string"],
temperature=1,
top_k=5,
top_p=0.7,
betas=["string"],
)
completion_stream.response.close()
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the TestCompletions class?
TestCompletions is a class in the anthropic-sdk-python codebase, defined in tests/api_resources/test_completions.py.
Where is TestCompletions defined?
TestCompletions is defined in tests/api_resources/test_completions.py at line 17.
What does TestCompletions extend?
TestCompletions extends Completion.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free