Skip to content

Honor streaming responses in TestClient#3258

Open
ShipItAndPray wants to merge 1 commit into
Kludex:mainfrom
ShipItAndPray:fix-testclient-stream-1102
Open

Honor streaming responses in TestClient#3258
ShipItAndPray wants to merge 1 commit into
Kludex:mainfrom
ShipItAndPray:fix-testclient-stream-1102

Conversation

@ShipItAndPray

Copy link
Copy Markdown

Summary

  • keep the test client portal open while the app task streams the response body
  • return a real sync byte stream after the first http.response.body instead of buffering the full body up front
  • add a regression test that proves client.stream(...) becomes available before the streaming response completes

Testing

  • uv run pytest tests/test_testclient.py -k stream_response_is_available_after_first_chunk -q
  • uv run pytest tests/test_testclient.py -q
  • uv run pytest tests/test_templates.py -q
  • uv run ruff check starlette/testclient.py tests/test_testclient.py

Fixes #1102

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestClient.request does not honor stream=True

2 participants