Skip to content

Commit

Permalink
chore(internal): remove redundant client test (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 17, 2024
1 parent 3671aa6 commit d7140f7
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from anthropic._types import Omit
from anthropic._client import Anthropic, AsyncAnthropic
from anthropic._models import BaseModel, FinalRequestOptions
from anthropic._response import APIResponse, AsyncAPIResponse
from anthropic._constants import RAW_RESPONSE_HEADER
from anthropic._streaming import Stream, AsyncStream
from anthropic._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
Expand Down Expand Up @@ -772,29 +771,6 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]

@mock.patch("anthropic._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_streaming_response(self) -> None:
response = self.client.post(
"/v1/complete",
body=dict(
max_tokens_to_sample=300,
model="claude-2.1",
prompt="\n\nHuman:Where can I get a good coffee in my neighbourhood?\n\nAssistant:",
),
cast_to=APIResponse[bytes],
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)

assert not cast(Any, response.is_closed)
assert _get_open_connections(self.client) == 1

for _ in response.iter_bytes():
...

assert cast(Any, response.is_closed)
assert _get_open_connections(self.client) == 0

@mock.patch("anthropic._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
Expand Down Expand Up @@ -1568,29 +1544,6 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]

@mock.patch("anthropic._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_streaming_response(self) -> None:
response = await self.client.post(
"/v1/complete",
body=dict(
max_tokens_to_sample=300,
model="claude-2.1",
prompt="\n\nHuman:Where can I get a good coffee in my neighbourhood?\n\nAssistant:",
),
cast_to=AsyncAPIResponse[bytes],
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)

assert not cast(Any, response.is_closed)
assert _get_open_connections(self.client) == 1

async for _ in response.iter_bytes():
...

assert cast(Any, response.is_closed)
assert _get_open_connections(self.client) == 0

@mock.patch("anthropic._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
Expand Down

0 comments on commit d7140f7

Please sign in to comment.