MCPcopy
hub / github.com/django/django / test_chunked

Method test_chunked

tests/view_tests/tests/test_static.py:41–53  ·  view source on GitHub ↗

The static view should stream files in chunks to avoid large memory usage

(self)

Source from the content-addressed store, hash-verified

39 )
40
41 def test_chunked(self):
42 """
43 The static view should stream files in chunks to avoid large memory
44 usage
45 """
46 response = self.client.get("/%s/%s" % (self.prefix, "long-line.txt"))
47 response_iterator = iter(response)
48 first_chunk = next(response_iterator)
49 self.assertEqual(len(first_chunk), FileResponse.block_size)
50 second_chunk = next(response_iterator)
51 response.close()
52 # strip() to prevent OS line endings from causing differences
53 self.assertEqual(len(second_chunk.strip()), 1449)
54
55 def test_unknown_mime_type(self):
56 response = self.client.get("/%s/file.unknown" % self.prefix)

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected