MCPcopy Create free account
hub / github.com/openai/openai-python / test_multiple_data_lines

Function test_multiple_data_lines

tests/test_streaming.py:148–162  ·  view source on GitHub ↗
(sync: bool, client: OpenAI, async_client: AsyncOpenAI)

Source from the content-addressed store, hash-verified

146@pytest.mark.asyncio
147@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
148async def test_multiple_data_lines(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
149 def body() -> Iterator[bytes]:
150 yield b"event: ping\n"
151 yield b"data: {\n"
152 yield b'data: "foo":\n'
153 yield b"data: true}\n"
154 yield b"\n\n"
155
156 iterator = make_event_iterator(content=body(), sync=sync, client=client, async_client=async_client)
157
158 sse = await iter_next(iterator)
159 assert sse.event == "ping"
160 assert sse.json() == {"foo": True}
161
162 await assert_empty_iter(iterator)
163
164
165@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected