#29268: Support passing content_type=None to test.Client.post() to get the 
default
value
---------------------------------------------+------------------------
               Reporter:  Chris Jerdonek     |          Owner:  nobody
                   Type:  New feature        |         Status:  new
              Component:  Testing framework  |        Version:  2.0
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 Currently, passing `content_type=None` to
 
[https://github.com/django/django/blob/76ae1e9a94cbfddbbf115ad96f26901ba5c02d44/django/test/client.py#L532
 `test.Client.post()`] results in the following error:

 {{{
 TypeError: expected string or bytes-like object
 }}}

 instead of causing the default `content_type` value. It would be more
 user-friendly if passing `None` resulted in the default value.

 One reason is as follows. Currently, if one wants to create a wrapper
 function around `post()` with the same default behavior, the user either
 needs to (1) duplicate / hard-code the default value in their wrapper
 function, or (2) special-case `None` with a second invocation of `post()`
 using a different function signature (i.e. one that doesn't pass //any//
 `content_type` value). You can even see this happening in `client.py` with
 the way that `Client.post()` invokes `RequestFactory.post()` -- the
 default needs to be hard-coded twice.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.089e1c4fabca7d91415f5d86fb7a089a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to