Skip to content

test(typespec-python): update streaming JSONL tests for type-driven Stream[T] - #5186

Closed
Libba Lawrence (l0lawrence) wants to merge 1 commit into
Azure:mainfrom
l0lawrence:l0lawrence-streaming-type-driven-tests
Closed

test(typespec-python): update streaming JSONL tests for type-driven Stream[T]#5186
Libba Lawrence (l0lawrence) wants to merge 1 commit into
Azure:mainfrom
l0lawrence:l0lawrence-streaming-type-driven-tests

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

Companion to microsoft/typespec#11579.

That PR makes structured streaming type-driven in @typespec/http-client-python: an operation whose HTTP response is a JSONL (application/jsonl) or SSE (text/event-stream) stream now generates receive() returning Stream[T] / AsyncStream[T] (Azure flavor, from a vendored _utils/streaming_base.py runtime) instead of the raw Iterator[bytes] / AsyncIterator[bytes]. The unbranded flavor keeps the byte-iterator behavior.

The committed mock_api streaming tests here assert the old byte contract for the azure flavor, so they break once the new core is swapped in by the Mock API Tests integration job. This PR updates them to match the new type-driven behavior:

  • shared/test_streaming_jsonl.py (+ async): keep only test_basic_sendreceive() now differs per flavor, so it is no longer a shared assertion.
  • azure/test_streaming_structured.py (new): asserts the structured Stream[T] / AsyncStream[T] receive() for JSONL (homogeneous Info models) and SSE (homogeneous + heterogeneous, terminating at [DONE]). Imports are guarded so collection never errors when a package is absent.
  • unbranded/test_streaming_jsonl_unbranded.py (+ async, new): asserts the unbranded byte-iterator receive().

These mirror the equivalent tests in microsoft/typespec#11579. Should be merged together with (or right after) that PR.

…tream[T]

Structured streaming is now type-driven in @typespec/http-client-python: an
operation whose HTTP response is a JSONL/SSE stream generates receive() returning
Stream[T]/AsyncStream[T] (Azure flavor) instead of Iterator[bytes]. Update the
committed mock_api streaming tests to match:

- shared/: keep only test_basic_send (recv now depends on flavor)
- azure/test_streaming_structured.py: assert structured Stream[T] recv (guarded)
- unbranded/: assert the byte-iterator recv (unbranded keeps Iterator[bytes])

Companion to microsoft/typespec#11579.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:python Issues for @azure-tools/typespec-python emitter label Aug 7, 2026
@l0lawrence
Libba Lawrence (l0lawrence) deleted the l0lawrence-streaming-type-driven-tests branch August 7, 2026 15:55
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @azure-tools/typespec-python
Show changes

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📦 Package size report

1 package changed size compared to the base branch.

Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-java 13.51 MB → 13.51 MB +163 B (+0.0%) 15.03 MB → 15.03 MB
44 unchanged package(s)
Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/azure-http-specs 146.21 KB → 146.21 KB 1.16 MB → 1.16 MB
@azure-tools/typespec-autorest 80.93 KB → 80.93 KB 395.06 KB → 395.06 KB
@azure-tools/typespec-autorest-canonical 7.42 KB → 7.42 KB 26.00 KB → 26.00 KB
@azure-tools/typespec-azure-core 127.87 KB → 127.87 KB 695.48 KB → 695.48 KB
@azure-tools/typespec-azure-portal-core 42.26 KB → 42.26 KB 192.36 KB → 192.36 KB
@azure-tools/typespec-azure-resource-manager 171.18 KB → 171.18 KB 1.04 MB → 1.04 MB
@azure-tools/typespec-azure-rulesets 5.15 KB → 5.15 KB 31.73 KB → 31.73 KB
@azure-tools/typespec-client-generator-core 225.96 KB → 225.96 KB 1.22 MB → 1.22 MB
@azure-tools/typespec-go 242.43 KB → 242.43 KB 1.24 MB → 1.24 MB
@azure-tools/typespec-metadata 15.91 KB → 15.91 KB 62.26 KB → 62.26 KB
@azure-tools/typespec-python 46.21 KB → 46.21 KB 180.83 KB → 180.83 KB
@azure-tools/typespec-ts 524.66 KB → 524.66 KB 2.53 MB → 2.53 MB
@typespec/asset-emitter 33.73 KB → 33.73 KB 158.67 KB → 158.67 KB
@typespec/bundler 11.31 KB → 11.31 KB 41.97 KB → 41.97 KB
@typespec/compiler 762.04 KB → 762.04 KB 3.88 MB → 3.88 MB
@typespec/emitter-framework 273.87 KB → 273.87 KB 1.50 MB → 1.50 MB
@typespec/events 8.96 KB → 8.96 KB 35.22 KB → 35.22 KB
@typespec/graphql 131.35 KB → 131.35 KB 544.77 KB → 544.77 KB
@typespec/html-program-viewer 53.96 KB → 53.96 KB 218.99 KB → 218.99 KB
@typespec/http 103.94 KB → 103.94 KB 511.18 KB → 511.18 KB
@typespec/http-canonicalization 74.18 KB → 74.18 KB 478.11 KB → 478.11 KB
@typespec/http-client 56.52 KB → 56.52 KB 281.75 KB → 281.75 KB
@typespec/http-client-js 219.98 KB → 219.98 KB 1.06 MB → 1.06 MB
@typespec/http-server-csharp 100.97 KB → 100.97 KB 409.91 KB → 409.91 KB
@typespec/http-server-js 259.10 KB → 259.10 KB 1.27 MB → 1.27 MB
@typespec/http-specs 182.15 KB → 182.15 KB 1.26 MB → 1.26 MB
@typespec/json-schema 31.66 KB → 31.66 KB 155.69 KB → 155.69 KB
@typespec/library-linter 4.35 KB → 4.35 KB 12.71 KB → 12.71 KB
@typespec/mutator-framework 71.87 KB → 71.87 KB 462.42 KB → 462.42 KB
@typespec/openapi 20.62 KB → 20.62 KB 91.67 KB → 91.67 KB
@typespec/openapi3 160.96 KB → 160.96 KB 824.53 KB → 824.53 KB
@typespec/playground 59.09 KB → 59.09 KB 239.02 KB → 239.02 KB
@typespec/prettier-plugin-typespec 157.35 KB → 157.35 KB 817.89 KB → 817.89 KB
@typespec/protobuf 94.53 KB → 94.53 KB 400.95 KB → 400.95 KB
@typespec/rest 24.18 KB → 24.18 KB 125.95 KB → 125.95 KB
@typespec/spec-api 46.54 KB → 46.54 KB 210.02 KB → 210.02 KB
@typespec/spec-coverage-sdk 41.83 KB → 41.83 KB 190.89 KB → 190.89 KB
@typespec/spector 139.66 KB → 139.66 KB 590.91 KB → 590.91 KB
@typespec/sse 5.66 KB → 5.66 KB 19.01 KB → 19.01 KB
@typespec/streams 4.12 KB → 4.12 KB 12.47 KB → 12.47 KB
@typespec/tspd 97.82 KB → 97.82 KB 430.99 KB → 430.99 KB
@typespec/versioning 36.69 KB → 36.69 KB 201.84 KB → 201.84 KB
@typespec/xml 9.41 KB → 9.41 KB 39.14 KB → 39.14 KB
tmlanguage-generator 5.00 KB → 5.00 KB 15.32 KB → 15.32 KB

Packed = gzipped .tgz published to npm. Unpacked = total extracted size. 🆕 added, 🗑️ removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:python Issues for @azure-tools/typespec-python emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant