AssertRedirects test method tests the status code of initial response instead of the last redirect
|Reported by:||Jukka Välimaa||Owned by:||nobody|
|Cc:||Jukka Välimaa||Triage Stage:||Unreviewed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In assertRedirects method of TestCase, the named parameter "target_status_code" should, according to the documentation, test the status code of the final point of the redirect chain. It is compared to the status code of the first redirecting response instead.
This is how the code is:
url, status_code = response.redirect_chain[-1] self.assertEqual(response.status_code, target_status_code, msg_prefix + "Response didn't redirect as expected: Final" " Response code was %d (expected %d)" % (response.status_code, target_status_code))
Unless I've misunderstood something, the last line there should use "status_code" instead of "response.status_code".