MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / async_client

Function async_client

tests/conftest.py:124–146  ·  view source on GitHub ↗
(request: FixtureRequest)

Source from the content-addressed store, hash-verified

122
123@pytest.fixture(scope="session")
124async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncAnthropic]:
125 param = getattr(request, "param", True)
126
127 # defaults
128 strict = True
129 http_client: None | httpx2.AsyncClient = None
130
131 if isinstance(param, bool):
132 strict = param
133 elif is_dict(param):
134 strict = param.get("strict", True)
135 assert isinstance(strict, bool)
136
137 http_client_type = param.get("http_client", "httpx")
138 if http_client_type == "aiohttp":
139 http_client = DefaultAioHttpClient()
140 else:
141 raise TypeError(f"Unexpected fixture parameter type {type(param)}, expected bool or dict")
142
143 async with AsyncAnthropic(
144 base_url=base_url, api_key=api_key, _strict_response_validation=strict, http_client=http_client
145 ) as client:
146 yield client

Callers

nothing calls this directly

Calls 3

is_dictFunction · 0.90
AsyncAnthropicClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected