MCPcopy
hub / github.com/openai/openai-python / test_basic

Function test_basic

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

Source from the content-addressed store, hash-verified

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

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