Home / File/ test_completions.py — anthropic-sdk-python Source File

test_completions.py — anthropic-sdk-python Source File

Architecture documentation for test_completions.py, a python file in the anthropic-sdk-python codebase. 7 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87["test_completions.py"]
  bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> bb0af148_44a9_df40_49c4_0fa6ceb5a403
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> d10c5377_2939_0f0b_cc44_8759393f2853
  cf46c35e_ae7e_a652_f32b_5dd703f4d658["utils.py"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> cf46c35e_ae7e_a652_f32b_5dd703f4d658
  08e9c9e7_d7f9_615f_5837_b3de69122e37["assert_matches_type"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> 08e9c9e7_d7f9_615f_5837_b3de69122e37
  96be2c65_41eb_5f34_98ec_2f14a3932c96["anthropic.types"]
  7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 --> 96be2c65_41eb_5f34_98ec_2f14a3932c96
  style 7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import os
from typing import Any, cast

import pytest

from anthropic import Anthropic, AsyncAnthropic
from tests.utils import assert_matches_type
from anthropic.types import Completion

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")


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(
// ... (181 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does test_completions.py do?
test_completions.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, Authentication subdomain.
What does test_completions.py depend on?
test_completions.py imports 7 module(s): anthropic, anthropic.types, assert_matches_type, os, pytest, typing, utils.py.
Where is test_completions.py in the architecture?
test_completions.py is located at tests/api_resources/test_completions.py (domain: AnthropicClient, subdomain: Authentication, directory: tests/api_resources).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free