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

Function async_client

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

Source from the content-addressed store, hash-verified

108
109@pytest.fixture(scope="session")
110async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncAnthropic]:
111 param = getattr(request, "param", True)
112
113 # defaults
114 strict = True
115 http_client: None | httpx2.AsyncClient = None
116
117 if isinstance(param, bool):
118 strict = param
119 elif is_dict(param):
120 strict = param.get("strict", True)
121 assert isinstance(strict, bool)
122
123 http_client_type = param.get("http_client", "httpx")
124 if http_client_type == "aiohttp":
125 http_client = DefaultAioHttpClient()
126 else:
127 raise TypeError(f"Unexpected fixture parameter type {type(param)}, expected bool or dict")
128
129 async with AsyncAnthropic(
130 base_url=base_url, api_key=api_key, _strict_response_validation=strict, http_client=http_client
131 ) as client:
132 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