diff options
| author | Alexandre Spaeth <Alexerson@users.noreply.github.com> | 2023-02-15 15:16:51 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-17 10:48:04 +0100 |
| commit | 52b054824e899db40ba48f908a9a00dadc56cb89 (patch) | |
| tree | c9dd57862164ea6d58d3e72f08f5e2509e2f0e5e /tests/handlers/tests.py | |
| parent | bfb8fda3e69cc6f5c6695ba70117faff51cc25a9 (diff) | |
Fixed #34342, Refs #33735 -- Fixed test client handling of async streaming responses.
Bug in 0bd2c0c9015b53c41394a1c0989afbfd94dc2830.
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Diffstat (limited to 'tests/handlers/tests.py')
| -rw-r--r-- | tests/handlers/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index 0df481c2fc..0348b8e5d6 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -253,6 +253,16 @@ class HandlerRequestTests(SimpleTestCase): self.assertEqual(response.status_code, 200) self.assertEqual(b"".join(list(response)), b"streaming content") + def test_async_streaming(self): + response = self.client.get("/async_streaming/") + self.assertEqual(response.status_code, 200) + msg = ( + "StreamingHttpResponse must consume asynchronous iterators in order to " + "serve them synchronously. Use a synchronous iterator instead." + ) + with self.assertWarnsMessage(Warning, msg): + self.assertEqual(b"".join(list(response)), b"streaming content") + class ScriptNameTests(SimpleTestCase): def test_get_script_name(self): @@ -329,3 +339,10 @@ class AsyncHandlerRequestTests(SimpleTestCase): self.assertEqual( b"".join([chunk async for chunk in response]), b"streaming content" ) + + async def test_async_streaming(self): + response = await self.async_client.get("/async_streaming/") + self.assertEqual(response.status_code, 200) + self.assertEqual( + b"".join([chunk async for chunk in response]), b"streaming content" + ) |
