1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #4988 -- In the test client, Added tracking of the client and request that caused a response so that the assertRedirects check can use the correct client when following a redirect. Well spotted, alex@gc-web.de.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6039 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2007-09-03 11:21:40 +00:00
parent afc6985267
commit 3bf4ef0c77
7 changed files with 57 additions and 14 deletions

View File

@@ -182,6 +182,10 @@ class Client:
if self.exc_info:
raise self.exc_info[1], None, self.exc_info[2]
# Save the client and request that stimulated the response
response.client = self
response.request = request
# Add any rendered template detail to the response
# If there was only one template rendered (the most likely case),
# flatten the list to a single element

View File

@@ -80,7 +80,9 @@ class TestCase(unittest.TestCase):
self.assertEqual(url, expected_url,
"Response redirected to '%s', expected '%s'" % (url, expected_url))
redirect_response = self.client.get(path, QueryDict(query))
# Get the redirection page, using the same client that was used
# to obtain the original response.
redirect_response = response.client.get(path, QueryDict(query))
self.assertEqual(redirect_response.status_code, target_status_code,
"Couldn't retrieve redirection page '%s': response code was %d (expected %d)" %
(path, redirect_response.status_code, target_status_code))