1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34342, Refs #33735 -- Fixed test client handling of async streaming responses.

Bug in 0bd2c0c901.

Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
This commit is contained in:
Alexandre Spaeth
2023-02-15 15:16:51 -08:00
committed by Mariusz Felisiak
parent bfb8fda3e6
commit 52b054824e
4 changed files with 53 additions and 9 deletions

View File

@@ -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"
)