Support streaming in ASGITransport

TJ
3mo ago
+107-75

Summary

This changes ASGITransport to support streaming responses, so you can use ASGITransport to test things like SSE.

I wrote this without realizing that PR #1032 by @Kludex, which aims to achieve the same thing, exists. The basic idea is the same: run the app in a separate task.

The reason I'm opening this PR in competition with #1032 is that currently, #1032 breaks some websocket tests (after merging main)

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

→ IMHO this doesn't need to be mentioned explicitly anywhere as it just implements the intuitive and expected behaviour for an ASGITransport. It doesn't contradict anything in the current docs that I can see. I could of course add a note to the docs like #1032 if this is deemed necessary.