Opened 23 months ago
Last modified 23 months ago
#34240 closed Bug
assertRedirects() doesn't preserve headers set in RequestFactory/Client methods. — at Version 4
Reported by: | Mariusz Felisiak | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Release blocker | Keywords: | |
Cc: | David Wobrock, Adam Johnson | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Similar to the #28337, HTTP headers can be passed in the headers
argument and should be preserved in assertRedirects()
.
-
tests/test_client_regress/tests.py
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py index aaf25e2ec4..53cdc3bf07 100644
a b class AssertRedirectsTests(SimpleTestCase): 613 613 status_code=302, 614 614 target_status_code=302, 615 615 ) 616 response = req_method( 617 "/redirect_based_on_extra_headers_1/", 618 follow=False, 619 headers={"redirect": "val"}, 620 ) 621 self.assertRedirects( 622 response, 623 "/redirect_based_on_extra_headers_2/", 624 fetch_redirect_response=True, 625 status_code=302, 626 target_status_code=302, 627 ) 616 628 617 629 618 630 @override_settings(ROOT_URLCONF="test_client_regress.urls")
Change History (4)
comment:2 by , 23 months ago
Triage Stage: | Unreviewed → Accepted |
---|
I'll provisionally accept anyhow, assuming you're correct about the regression.
comment:3 by , 23 months ago
Replying to Carlton Gibson:
I think the regression test here isn't quite right. It fails at b181cae2e3697b2e53b5b67ac67e59f3b05a6f0d (i.e.
67da22f0^
) andstable/4.1.x
too. 🤔
Support for headers
was added in 67da22f08e05018ea968fcacbac9ac37ea925d85, so it's a bug in the new feature. Previously, headers
went to **extra
and was not interpreted as HTTP headers.
After 67da22f08e05018ea968fcacbac9ac37ea925d85 headers={"redirect": "val"}
should work the same as HTTP_REDIRECT="val"
and is not in assertRedirects()
.
comment:4 by , 23 months ago
Description: | modified (diff) |
---|
I think the regression test here isn't quite right. It fails at b181cae2e3697b2e53b5b67ac67e59f3b05a6f0d (i.e.
67da22f0^
) andstable/4.1.x
too. 🤔