mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #34342 -- Added tests for handling sync streaming responses by test client.
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
This commit is contained in:
committed by
Mariusz Felisiak
parent
8eef22dfed
commit
bfb8fda3e6
@@ -41,9 +41,10 @@ class StaticTests(SimpleTestCase):
|
||||
def test_chunked(self):
|
||||
"The static view should stream files in chunks to avoid large memory usage"
|
||||
response = self.client.get("/%s/%s" % (self.prefix, "long-line.txt"))
|
||||
first_chunk = next(response.streaming_content)
|
||||
response_iterator = iter(response)
|
||||
first_chunk = next(response_iterator)
|
||||
self.assertEqual(len(first_chunk), FileResponse.block_size)
|
||||
second_chunk = next(response.streaming_content)
|
||||
second_chunk = next(response_iterator)
|
||||
response.close()
|
||||
# strip() to prevent OS line endings from causing differences
|
||||
self.assertEqual(len(second_chunk.strip()), 1449)
|
||||
|
||||
Reference in New Issue
Block a user