summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorUnai Zalakain <unai@gisa-elkartea.org>2013-11-19 09:44:30 +0100
committerTim Graham <timograham@gmail.com>2014-01-09 18:50:03 -0500
commit9eb16031ca837624433c49646289b50f9566a25d (patch)
tree25d846a41ab1b00349c6a63a18b6bc258641fbe2 /tests
parent9ae17d994b1b0dee952c2e64f3727ce7a6ffb398 (diff)
Fixed #12571 -- Attached originating WSGIRequest to test client responses.
Originating WSGIRequests are now attached to the ``wsgi_request`` attribute of the ``HttpResponse`` returned by the testing client. Thanks rvdrijst for the suggestion.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_client/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 3693b33752..5fa6360eda 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -84,6 +84,20 @@ class ClientTest(TestCase):
self.assertEqual(response['X-DJANGO-TEST'], 'Slartibartfast')
+ def test_response_attached_request(self):
+ """
+ Check that the returned response has a ``request`` attribute with the
+ originating environ dict and a ``wsgi_request`` with the originating
+ ``WSGIRequest`` instance.
+ """
+ response = self.client.get("/test_client/header_view/")
+
+ self.assertTrue(hasattr(response, 'request'))
+ self.assertTrue(hasattr(response, 'wsgi_request'))
+ for key, value in response.request.items():
+ self.assertIn(key, response.wsgi_request.environ)
+ self.assertEqual(response.wsgi_request.environ[key], value)
+
def test_raw_post(self):
"POST raw data (with a content type) to a view"
test_doc = """<?xml version="1.0" encoding="utf-8"?><library><book><title>Blink</title><author>Malcolm Gladwell</author></book></library>"""