MCPcopy
hub / github.com/django/django / test_file_wrapper

Method test_file_wrapper

tests/wsgi/tests.py:65–90  ·  view source on GitHub ↗

FileResponse uses wsgi.file_wrapper.

(self)

Source from the content-addressed store, hash-verified

63 self.assertIn(("Set-Cookie", "key=value; Path=/"), response_data["headers"])
64
65 def test_file_wrapper(self):
66 """
67 FileResponse uses wsgi.file_wrapper.
68 """
69
70 class FileWrapper:
71 def __init__(self, filelike, block_size=None):
72 self.block_size = block_size
73 filelike.close()
74
75 application = get_wsgi_application()
76 environ = self.request_factory._base_environ(
77 PATH_INFO="/file/",
78 REQUEST_METHOD="GET",
79 **{"wsgi.file_wrapper": FileWrapper},
80 )
81 response_data = {}
82
83 def start_response(status, headers):
84 response_data["status"] = status
85 response_data["headers"] = headers
86
87 response = application(environ, start_response)
88 self.assertEqual(response_data["status"], "200 OK")
89 self.assertIsInstance(response, FileWrapper)
90 self.assertEqual(response.block_size, FileResponse.block_size)
91
92
93class GetInternalWSGIApplicationTest(SimpleTestCase):

Callers

nothing calls this directly

Calls 2

get_wsgi_applicationFunction · 0.90
_base_environMethod · 0.80

Tested by

no test coverage detected