Open havardthom opened 2 years ago
You've identified this correctly in your comment here... https://github.com/encode/httpx/discussions/1787#discussioncomment-1537543
The issue is that the ASGITransport doesn't stream responses. I've retitled this issue to be more specific regarding what's needed to resolve this.
@tomchristie Is there any update on this one ? Or has it already been fixed ?
As mentioned in havardthom's comment, I had a previous PR from a long time ago here which attempted to solve something that would resolve this: https://github.com/encode/httpx/pull/998
It's okay to start off that PR, adjusting anything that needs to be due to changes in HTTPX since then.
If no one takes this until the end of the year, I will.
EDIT on 28 July 2023: I lied.
I've run into the same issue, and unfortunately @florimondmanca's branch didn't work for me (all requests hang, not just SSE streams). I used that as inspiration though, and am monkey patching the transport in my tests. Here's a gist: https://gist.github.com/richardhundt/17dfccb5c1e253f798999fc2b2417d7e
My suggestion would be that we document this as a known constraint.
If someone is invested in resolving it, then implementing it as a third party transport would be a good first step.
I've got the same problem - FastAPI SSE endpoint I'd like to test. Is there a workaround for this?
Current behaviour:
uvicorn test_endless_sse:app --reload
thenpython test_endless_sse.py
works.pytest test_endless_sse.py
hangs forever.Expected behaviour:
pytest test_endless_sse.py
should passRelated: https://github.com/tiangolo/fastapi/issues/2006