Opened 6 years ago

Closed 6 years ago

#13604 closed (invalid)

AssertRedirects test method tests the status code of initial response instead of the last redirect

Reported by: Jukka Välimaa Owned by: nobody
Component: Testing framework Version: 1.2
Severity: Keywords: assertRedirects
Cc: Jukka Välimaa Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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".

Change History (1)

comment:1 Changed 6 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: invalid
Status: newclosed

As far as I can make out, the current behaviour is correct, and there are a number of test cases in the test_client_regress suite to verify that the behavior works as expected. If you made the change you describe, you would be testing against the response from the last redirect, not the response that served the final page.

Note: See TracTickets for help on using tickets.
Back to Top