summaryrefslogtreecommitdiff
path: root/tests/handlers/tests.py
diff options
context:
space:
mode:
authorAlexandre Spaeth <Alexerson@users.noreply.github.com>2023-02-15 15:16:51 -0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-17 10:48:04 +0100
commit52b054824e899db40ba48f908a9a00dadc56cb89 (patch)
treec9dd57862164ea6d58d3e72f08f5e2509e2f0e5e /tests/handlers/tests.py
parentbfb8fda3e69cc6f5c6695ba70117faff51cc25a9 (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.py17
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"
+ )