MCPcopy
hub / github.com/anthropics/anthropic-sdk-python / test_basic

Function test_basic

tests/test_streaming.py:17–29  ·  view source on GitHub ↗
(sync: bool, client: Anthropic, async_client: AsyncAnthropic)

Source from the content-addressed store, hash-verified

15@pytest.mark.asyncio
16@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
17async def test_basic(sync: bool, client: Anthropic, async_client: AsyncAnthropic) -> None:
18 def body() -> Iterator[bytes]:
19 yield b"event: completion\n"
20 yield b'data: {"foo":true}\n'
21 yield b"\n"
22
23 iterator = make_event_iterator(content=body(), sync=sync, client=client, async_client=async_client)
24
25 sse = await iter_next(iterator)
26 assert sse.event == "completion"
27 assert sse.json() == {"foo": True}
28
29 await assert_empty_iter(iterator)
30
31
32@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 5

make_event_iteratorFunction · 0.85
bodyFunction · 0.70
iter_nextFunction · 0.70
assert_empty_iterFunction · 0.70
jsonMethod · 0.45

Tested by

no test coverage detected