Loading django/test/client.py +6 −2 Original line number Diff line number Diff line Loading @@ -182,12 +182,16 @@ class RequestFactory(object): """ The base environment for a request. """ # This is a minimal valid WSGI environ dictionary, plus HTTP_COOKIE # for cookie support. Empty strings are omitted. # This is a minimal valid WSGI environ dictionary, plus: # - HTTP_COOKIE: for cookie support, # - REMOTE_ADDR: often useful, see #8551. # See http://www.python.org/dev/peps/pep-3333/#environ-variables environ = { 'HTTP_COOKIE': self.cookies.output(header='', sep='; '), 'PATH_INFO': '/', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testserver', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1', Loading tests/regressiontests/test_client_regress/models.py +20 −0 Original line number Diff line number Diff line Loading @@ -994,3 +994,23 @@ class RequestFactoryStateTest(TestCase): def test_request_after_client_2(self): # This test is executed after the previous one self.common_test_that_should_always_pass() class RequestFactoryEnvironmentTests(TestCase): """ Regression tests for #8551 and #17067: ensure that environment variables are set correctly in RequestFactory. """ def setUp(self): self.factory = RequestFactory() def test_should_set_correct_env_variables(self): request = self.factory.get('/path/') self.assertEqual(request.META.get('REMOTE_ADDR'), '127.0.0.1') self.assertEqual(request.META.get('SERVER_NAME'), 'testserver') self.assertEqual(request.META.get('SERVER_PORT'), '80') self.assertEqual(request.META.get('SERVER_PROTOCOL'), 'HTTP/1.1') self.assertEqual(request.META.get('SCRIPT_NAME') + request.META.get('PATH_INFO'), '/path/') Loading
django/test/client.py +6 −2 Original line number Diff line number Diff line Loading @@ -182,12 +182,16 @@ class RequestFactory(object): """ The base environment for a request. """ # This is a minimal valid WSGI environ dictionary, plus HTTP_COOKIE # for cookie support. Empty strings are omitted. # This is a minimal valid WSGI environ dictionary, plus: # - HTTP_COOKIE: for cookie support, # - REMOTE_ADDR: often useful, see #8551. # See http://www.python.org/dev/peps/pep-3333/#environ-variables environ = { 'HTTP_COOKIE': self.cookies.output(header='', sep='; '), 'PATH_INFO': '/', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testserver', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1', Loading
tests/regressiontests/test_client_regress/models.py +20 −0 Original line number Diff line number Diff line Loading @@ -994,3 +994,23 @@ class RequestFactoryStateTest(TestCase): def test_request_after_client_2(self): # This test is executed after the previous one self.common_test_that_should_always_pass() class RequestFactoryEnvironmentTests(TestCase): """ Regression tests for #8551 and #17067: ensure that environment variables are set correctly in RequestFactory. """ def setUp(self): self.factory = RequestFactory() def test_should_set_correct_env_variables(self): request = self.factory.get('/path/') self.assertEqual(request.META.get('REMOTE_ADDR'), '127.0.0.1') self.assertEqual(request.META.get('SERVER_NAME'), 'testserver') self.assertEqual(request.META.get('SERVER_PORT'), '80') self.assertEqual(request.META.get('SERVER_PROTOCOL'), 'HTTP/1.1') self.assertEqual(request.META.get('SCRIPT_NAME') + request.META.get('PATH_INFO'), '/path/')