Opened 4 years ago
Closed 4 years ago
#32929 closed Bug (fixed)
AsyncRequestFactory.get() ignores data parameter
| Reported by: | Pochang Lee | Owned by: | Pochang Lee |
|---|---|---|---|
| Component: | Testing framework | Version: | dev |
| Severity: | Normal | Keywords: | AsyncTestClient, AsyncRequestFactory |
| Cc: | Andrew Godwin, Carlton Gibson | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When passing data to AsyncRequestFactory.get(),
the resulting request.GET always gives an empty QueryDict
>>> request_factory = AsyncRequestFactory()
>>> request = request_factory.get('/somewhere/', {'var': '100'})
>>> request.GET
<QueryDict: {}>
while in synchronous
>>> request_factory = RequestFactory()
>>> request = request_factory.get('/somewhere/', {'var': '100'})
>>> request.GET
<QueryDict: {'var': ['100']}>
This also prevents AsyncClient.get() from passing GET parameters to view function.
Change History (5)
comment:1 by , 4 years ago
| Version: | 3.2 → dev |
|---|
follow-up: 3 comment:2 by , 4 years ago
| Cc: | added |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 4 years ago
| Has patch: | set |
|---|
Replying to Mariusz Felisiak:
Would you like to prepare a patch? (tests are also required).
Yes, I have submitted a pull request.
comment:4 by , 4 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Note:
See TracTickets
for help on using tickets.
Thanks for the report, good catch. I think the following should do the trick:
diff --git a/django/test/client.py b/django/test/client.py index 4a0b6b45f4..b4c091aa5c 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -547,6 +547,8 @@ class AsyncRequestFactory(RequestFactory): follow = extra.pop('follow', None) if follow is not None: s['follow'] = follow + if query_string := extra.pop('QUERY_STRING', None): + s['query_string'] = query_string s['headers'] += [ (key.lower().encode('ascii'), value.encode('latin1')) for key, value in extra.items()Would you like to prepare a patch? (tests are also required).