Module

testing.sse

SSE testing utilities.

Provides structured parsing of Server-Sent Events responses for use in test assertions.

Classes

SSETestResult 4
Collected events from an SSE endpoint. Returned by ``TestClient.sse()`` after the connection close…

Collected events from an SSE endpoint.

Returned byTestClient.sse()after the connection closes.

Attributes

Name Type Description
events tuple[SSEEvent, ...]
heartbeats int
status int
headers dict[str, str]

Functions

parse_sse_frames 1 tuple[list[SSEEvent], in…
Parse raw SSE text into structured events and heartbeat count. Splits on doubl…
def parse_sse_frames(raw: str) -> tuple[list[SSEEvent], int]

Parse raw SSE text into structured events and heartbeat count.

Splits on double-newline boundaries. Each block is parsed into an SSEEvent. Comment lines (starting with :) are counted as heartbeats if they contain "heartbeat".

Parameters
Name Type Description
raw str
Returns
tuple[list[SSEEvent], int]