Code

Opened 4 years ago

Closed 4 years ago

#13604 closed (invalid)

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

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

Description

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

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.