MCPcopy
hub / github.com/django/django / test_get_wsgi_application

Method test_get_wsgi_application

tests/wsgi/tests.py:19–50  ·  view source on GitHub ↗

get_wsgi_application() returns a functioning WSGI callable.

(self)

Source from the content-addressed store, hash-verified

17 self.addCleanup(request_started.connect, close_old_connections)
18
19 def test_get_wsgi_application(self):
20 """
21 get_wsgi_application() returns a functioning WSGI callable.
22 """
23 application = get_wsgi_application()
24
25 environ = self.request_factory._base_environ(
26 PATH_INFO="/", CONTENT_TYPE="text/html; charset=utf-8", REQUEST_METHOD="GET"
27 )
28
29 response_data = {}
30
31 def start_response(status, headers):
32 response_data["status"] = status
33 response_data["headers"] = headers
34
35 response = application(environ, start_response)
36
37 self.assertEqual(response_data["status"], "200 OK")
38 self.assertEqual(
39 set(response_data["headers"]),
40 {("Content-Length", "12"), ("Content-Type", "text/html; charset=utf-8")},
41 )
42 self.assertIn(
43 bytes(response),
44 [
45 b"Content-Length: 12\r\nContent-Type: text/html; "
46 b"charset=utf-8\r\n\r\nHello World!",
47 b"Content-Type: text/html; "
48 b"charset=utf-8\r\nContent-Length: 12\r\n\r\nHello World!",
49 ],
50 )
51
52 def test_wsgi_cookies(self):
53 response_data = {}

Callers

nothing calls this directly

Calls 2

get_wsgi_applicationFunction · 0.90
_base_environMethod · 0.80

Tested by

no test coverage detected