Home / Function/ test_binary_content_upload_with_iterator() — anthropic-sdk-python Function Reference

test_binary_content_upload_with_iterator() — anthropic-sdk-python Function Reference

Architecture documentation for the test_binary_content_upload_with_iterator() function in test_client.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  aeefb179_ec5d_cd42_2e2d_23f41efad90d["test_binary_content_upload_with_iterator()"]
  d53b6c34_1743_a045_4be1_3554ab153964["TestAnthropic"]
  aeefb179_ec5d_cd42_2e2d_23f41efad90d -->|defined in| d53b6c34_1743_a045_4be1_3554ab153964
  ab46e5da_5c1b_aa8e_a901_3dc498b29f47["_make_sync_iterator()"]
  aeefb179_ec5d_cd42_2e2d_23f41efad90d -->|calls| ab46e5da_5c1b_aa8e_a901_3dc498b29f47
  style aeefb179_ec5d_cd42_2e2d_23f41efad90d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_client.py lines 583–608

    def test_binary_content_upload_with_iterator(self) -> None:
        file_content = b"Hello, this is a test file."
        counter = Counter()
        iterator = _make_sync_iterator([file_content], counter=counter)

        def mock_handler(request: httpx.Request) -> httpx.Response:
            assert counter.value == 0, "the request body should not have been read"
            return httpx.Response(200, content=request.read())

        with Anthropic(
            base_url=base_url,
            api_key=api_key,
            _strict_response_validation=True,
            http_client=httpx.Client(transport=MockTransport(handler=mock_handler)),
        ) as client:
            response = client.post(
                "/upload",
                content=iterator,
                cast_to=httpx.Response,
                options={"headers": {"Content-Type": "application/octet-stream"}},
            )

            assert response.status_code == 200
            assert response.request.headers["Content-Type"] == "application/octet-stream"
            assert response.content == file_content
            assert counter.value == 1

Subdomains

Frequently Asked Questions

What does test_binary_content_upload_with_iterator() do?
test_binary_content_upload_with_iterator() is a function in the anthropic-sdk-python codebase, defined in tests/test_client.py.
Where is test_binary_content_upload_with_iterator() defined?
test_binary_content_upload_with_iterator() is defined in tests/test_client.py at line 583.
What does test_binary_content_upload_with_iterator() call?
test_binary_content_upload_with_iterator() calls 1 function(s): _make_sync_iterator.

Analyze Your Own Codebase

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

Try Supermodel Free