Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions async_asgi_testclient/tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,13 @@ async def test_request_stream(starlette_app):
from starlette.responses import StreamingResponse

async def up_stream(request):
async def gen():
async for chunk in request.stream():
chunks = [chunk async for chunk in request.stream()]

async def gen(chunks):
for chunk in chunks:
yield chunk

return StreamingResponse(gen())
return StreamingResponse(gen(chunks))

starlette_app.add_route("/upload_stream", up_stream, methods=["POST"])

Expand Down Expand Up @@ -492,11 +494,13 @@ def gen():
return StreamingResponse(gen())

async def up_stream(request):
async def gen():
async for chunk in request.stream():
chunks = [chunk async for chunk in request.stream()]

async def gen(chunks):
for chunk in chunks:
yield chunk

return StreamingResponse(gen())
return StreamingResponse(gen(chunks))

starlette_app.add_route("/download_stream", down_stream, methods=["GET"])
starlette_app.add_route("/upload_stream", up_stream, methods=["POST"])
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
quart==0.17.0; python_version >= '3.7'
starlette==0.12.13
starlette==0.21.0
python-multipart==0.0.5
pytest==6.2.5
pytest-asyncio==0.15.0
Expand Down