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

Function test_multiple_events

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

Source from the content-addressed store, hash-verified

78@pytest.mark.asyncio
79@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
80async def test_multiple_events(sync: bool, client: Anthropic, async_client: AsyncAnthropic) -> None:
81 def body() -> Iterator[bytes]:
82 yield b"event: ping\n"
83 yield b"\n"
84 yield b"event: completion\n"
85 yield b"\n"
86
87 iterator = make_event_iterator(content=body(), sync=sync, client=client, async_client=async_client)
88
89 sse = await iter_next(iterator)
90 assert sse.event == "ping"
91 assert sse.data == ""
92
93 sse = await iter_next(iterator)
94 assert sse.event == "completion"
95 assert sse.data == ""
96
97 await assert_empty_iter(iterator)
98
99
100@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

make_event_iteratorFunction · 0.85
bodyFunction · 0.70
iter_nextFunction · 0.70
assert_empty_iterFunction · 0.70

Tested by

no test coverage detected