MCPcopy
hub / github.com/django/django / _base_environ

Method _base_environ

django/test/client.py:401–432  ·  view source on GitHub ↗

The base environment for a request.

(self, **request)

Source from the content-addressed store, hash-verified

399 self.defaults["QUERY_STRING"] = urlencode(query_params, doseq=True)
400
401 def _base_environ(self, **request):
402 """
403 The base environment for a request.
404 """
405 # This is a minimal valid WSGI environ dictionary, plus:
406 # - HTTP_COOKIE: for cookie support,
407 # - REMOTE_ADDR: often useful, see #8551.
408 # See https://www.python.org/dev/peps/pep-3333/#environ-variables
409 return {
410 "HTTP_COOKIE": "; ".join(
411 sorted(
412 "%s=%s" % (morsel.key, morsel.coded_value)
413 for morsel in self.cookies.values()
414 )
415 ),
416 "PATH_INFO": "/",
417 "REMOTE_ADDR": "127.0.0.1",
418 "REQUEST_METHOD": "GET",
419 "SCRIPT_NAME": "",
420 "SERVER_NAME": "testserver",
421 "SERVER_PORT": "80",
422 "SERVER_PROTOCOL": "HTTP/1.1",
423 "wsgi.version": (1, 0),
424 "wsgi.url_scheme": "http",
425 "wsgi.input": FakePayload(b""),
426 "wsgi.errors": self.errors,
427 "wsgi.multiprocess": True,
428 "wsgi.multithread": False,
429 "wsgi.run_once": False,
430 **self.defaults,
431 **request,
432 }
433
434 def request(self, **request):
435 "Construct a generic request object."

Callers 5

requestMethod · 0.95
requestMethod · 0.80
test_wsgi_cookiesMethod · 0.80
test_file_wrapperMethod · 0.80

Calls 3

FakePayloadClass · 0.85
joinMethod · 0.45
valuesMethod · 0.45

Tested by 3

test_wsgi_cookiesMethod · 0.64
test_file_wrapperMethod · 0.64