Files
wehub-resource-sync a7d6d88f6f
CI / changes (push) Has been cancelled
CI / cd libs/checkpoint (push) Has been cancelled
CI / cd libs/checkpoint-conformance (push) Has been cancelled
CI / cd libs/checkpoint-postgres (push) Has been cancelled
CI / cd libs/checkpoint-sqlite (push) Has been cancelled
CI / cd libs/cli (push) Has been cancelled
CI / cd libs/prebuilt (push) Has been cancelled
CI / cd libs/sdk-py (push) Has been cancelled
CI / cd libs/langgraph (push) Has been cancelled
CI / Check SDK methods matching (push) Has been cancelled
CI / Check CLI schema hasn't changed #3.13 (push) Has been cancelled
CI / CLI integration test (push) Has been cancelled
CI / sdk-py integration test (push) Has been cancelled
CI / CI Success (push) Has been cancelled
baseline / benchmark (push) Has been cancelled
Deploy Redirects to GitHub Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:37:18 +08:00

38 lines
1.3 KiB
Python

"""`thread.messages` projection (outer iter + inner `.text` token deltas)."""
from __future__ import annotations
import pytest
from .conftest import ASSISTANT_ID
pytestmark = pytest.mark.integration
async def test_messages_async(async_threads) -> None:
threads, _ = async_threads
async with threads.stream(assistant_id=ASSISTANT_ID) as thread:
await thread.run.start(input={"messages": [], "value": "init", "items": []})
# Drain the outer iterator first; iterating each inner `stream.text`
# while the outer is suspended deadlocks.
streams = [s async for s in thread.messages]
assert streams, "expected at least one streamed message"
for stream in streams:
text = "".join([t async for t in stream.text])
assert text == "Hello, world!", f"unexpected message text: {text!r}"
def test_messages_sync(sync_threads) -> None:
threads, _ = sync_threads
with threads.stream(assistant_id=ASSISTANT_ID) as thread:
thread.run.start(input={"messages": [], "value": "init", "items": []})
streams = list(thread.messages)
assert streams, "expected at least one streamed message"
for stream in streams:
text = "".join(list(stream.text))
assert text == "Hello, world!", f"unexpected message text: {text!r}"