You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thank you for creating this! This package is the only testing utility I've found that can consume and test an asgi streaming response (fastapi/starlette).
Inside this package, with newer versions of starlette, I do see some failures with some of the streaming tests.
It seems that starlette doesn't like reading the request body after starting the response. I changed the test to consume the request body and then start the response and this seems to work fine (#57).
I also created this example app without asgi-testclient to be sure it's not a bug in the test client, and it seems that the problem is in starlette:
# example.pyfromstarlette.applicationsimportStarlettefromstarlette.responsesimportStreamingResponseapp=Starlette()
asyncdefbuffered(request):
chunks= [chunkasyncforchunkinrequest.stream()]
asyncdefgen(chunks):
forchunkinchunks:
yieldchunkreturnStreamingResponse(gen(chunks))
asyncdefunbuffered(request):
returnStreamingResponse(request.stream())
app.add_route("/buffered", buffered, methods=["POST"])
app.add_route("/unbuffered", unbuffered, methods=["POST"])
"""1. Create a test filedd if=/dev/urandom of=./file count=1024 bs=10242. Run serveruvicorn example:app3. Check buffered stream workscurl -v -X POST localhost:8000/buffered --data-binary @file --output -4. Test unbuffered stream doesn't work (empty response)curl -v -X POST localhost:8000/unbuffered --data-binary @file --output -"""
I was going to open a discussion in Starlette but I found this one reporting a similar problem
First, thank you for creating this! This package is the only testing utility I've found that can consume and test an asgi streaming response (fastapi/starlette).
Inside this package, with newer versions of
starlette
, I do see some failures with some of the streaming tests.Starting in 0.13.3
test_upload_stream_from_download_stream
Then in 0.13.4, the same test starts to hang, instead of outright fail.
In 0.13.5, this test starts to hang as well.
test_request_stream
In the latest version of starlette, 0.21.0,
test_request_stream
hangs, whiletest_upload_stream_from_download_stream
fails with the following error:The text was updated successfully, but these errors were encountered: