Opened 85 minutes ago
Last modified 70 minutes ago
#36966 assigned Bug
Test client using query_params raises ValueError when following redirect
| Reported by: | Marc Gibbons | Owned by: | Marc Gibbons |
|---|---|---|---|
| Component: | Testing framework | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Marc Gibbons | Triage Stage: | Unreviewed |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When the test client is called with query_params and follow=True, a ValueError is raised when following the redirect.
_follow_redirect populates data from the redirect URL's query string via QueryDict(url.query). Since query_params from the original request is never reset, both data and query_params end up non-empty, triggering: ValueError: query_params and data arguments are mutually exclusive.
Reproduction
def test_follow_redirect_with_query_params(self):
self.client.get("/redirect_view/", query_params={"next": "x"}, follow=True) # this yells