Re: [Django] #14611: django.test.Client is missing post *and* get possibility

10 views
Skip to first unread message

Django

unread,
Dec 24, 2011, 11:15:35 AM12/24/11
to django-...@googlegroups.com
#14611: django.test.Client is missing post *and* get possibility
-----------------------------------+------------------------------------
Reporter: Ciantic | Owner: nobody
Type: New feature | Status: closed
Component: Testing framework | Version: 1.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by aaugustin):

* status: new => closed
* ui_ux: => 0
* resolution: => wontfix
* easy: => 0


Comment:

To be honest, the title of this ticket doesn't make much sense given how
HTTP works. There are two orthogonal mechanisms involved here:
- 1) HTTP methods
- `Client.get` performs a GET request;
- `Client.post` performs a POST request.
- 2) HTML forms
- when submitted with a GET, form data is encoded in the query string,
and Django exposes it in `request.GET`;
- when submitted with a POST, it's in the request body, and Django
exposes it in `request.POST`.

The `data` argument of the test client is designed to hold simulated form
data, and is automatically inserted in requests according to these rules.

----

That said, it's absolutely legal to use query string parameters in the URL
of a POST request. But that isn't be form data. Adding an argument called
`get_data` would be extremely confusing.

In addition, I'm not eager to add a `query_string_parameters` argument to
the test client, because Django favors clean URL design. I'm also afraid
of possible confusions with form data in GET requests.

So, for all these reasons, I'm going to reject this ticket. The
recommended solution is to use `self.client.post('/my/url/?param=value',
form_data)`.

--
Ticket URL: <https://code.djangoproject.com/ticket/14611#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 19, 2023, 5:58:59 PM6/19/23
to django-...@googlegroups.com
#14611: django.test.Client is missing post *and* get possibility
-----------------------------------+------------------------------------
Reporter: Jari Pennanen | Owner: nobody

Type: New feature | Status: closed
Component: Testing framework | Version: 1.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Dan Strokirk):

Would it be possible to reopen and reevaluate this ticket? It’s 11 years
later, and I feel this would be a great, simple addition to Django’s
testing toolset.

--
Ticket URL: <https://code.djangoproject.com/ticket/14611#comment:6>

Django

unread,
Jun 19, 2023, 11:22:35 PM6/19/23
to django-...@googlegroups.com
#14611: django.test.Client is missing post *and* get possibility
-----------------------------------+------------------------------------
Reporter: Jari Pennanen | Owner: nobody
Type: New feature | Status: closed
Component: Testing framework | Version: 1.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:6 Dan Strokirk]:


> Would it be possible to reopen and reevaluate this ticket? It’s 11 years
later, and I feel this would be a great, simple addition to Django’s
testing toolset.

For now, I don't see a consensus in the [https://forum.djangoproject.com/t
/suggestion-adding-params-to-testclient-http-methods/21246 discussion] and
we need it to reopen the ticket. I'd wait a little longer and get more
opinions.

--
Ticket URL: <https://code.djangoproject.com/ticket/14611#comment:7>

Django

unread,
Oct 4, 2023, 8:10:25 AM10/4/23
to django-...@googlegroups.com
#14611: django.test.Client is missing post *and* get possibility
-----------------------------------+------------------------------------
Reporter: Jari Pennanen | Owner: nobody
Type: New feature | Status: closed
Component: Testing framework | Version: 1.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Lily Foote):

Replying to [comment:7 Mariusz Felisiak]:


> Replying to [comment:6 Dan Strokirk]:
> > Would it be possible to reopen and reevaluate this ticket? It’s 11
years later, and I feel this would be a great, simple addition to Django’s
testing toolset.
>
> For now, I don't see a consensus in the
[https://forum.djangoproject.com/t/suggestion-adding-params-to-testclient-

http-methods/21246 discussion] and we need it to reopen the ticket. I'd


wait a little longer and get more opinions.

I think we have consensus in the linked thread and should reopen.

--
Ticket URL: <https://code.djangoproject.com/ticket/14611#comment:8>

Reply all
Reply to author
Forward
0 new messages