Opened 5 years ago

Closed 5 years ago

#16916 closed Cleanup/optimization (fixed)

Please document django.test.Client.defaults

Reported by: sailorfred@… Owned by: Raúl Cumplido
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Raúl Cumplido Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Aymeric Augustin)

The documentation makes it clear that I can provide an HTTP_USER_AGENT to the test client's methods, but it would have been nice to have it documented that the defaults exist, and how useful they are.

Attachments (1)

16916.diff (1.6 KB) - added by Raúl Cumplido 5 years ago.
First patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by Aymeric Augustin

Description: modified (diff)
Summary: Please document django.test.Class.defaultsPlease document django.test.Client.defaults
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Defaults can also be passed in Client.__init__. Basically, these values just update the WSGI environ dictionary. There is no fixed list.

The values from the keywords argument to theget/post/etc. methods have precedence, then those passed in __init__, and then the defaults.

Indeed, this isn't documented.

comment:2 Changed 5 years ago by Russell Keith-Magee

It is partially documented -- the **extra argument is listed, and an example (using HTTP_X_REQUESTED_WITH) is provided in the API docs for the test client. However, there is certainly room for a broad guide to the topic when the Test Client is introduced.

comment:3 Changed 5 years ago by Raúl Cumplido

Cc: Raúl Cumplido added
Owner: changed from nobody to Raúl Cumplido

comment:4 Changed 5 years ago by Raúl Cumplido

Status: newassigned

comment:5 Changed 5 years ago by Raúl Cumplido

Has patch: set

Hi I provide a first patch but I don't understand something in the comment from aaugustin:

The values from the keywords argument to theget/post/etc. methods have precedence, then those passed in __init__, and then the defaults.

I mean defaults are passed in __init__ then your comment shouldn't be something like this:

The values from the keywords argument to the get/post/etc. methods have precedence, than those defaults passed in __init__. Or I am missing something?

Changed 5 years ago by Raúl Cumplido

Attachment: 16916.diff added

First patch

comment:6 Changed 5 years ago by Christopher Medrela

Patch needs improvement: set

I think lines 694-695 are too deep - the indentation should be one level of depth (see deleted lines 672-673 in your patch).

comment:7 Changed 5 years ago by anonymous

Patch needs improvement: unset

Has a newer patch at github. Pull request at:
https://github.com/django/django/pull/115

comment:8 Changed 5 years ago by Aymeric Augustin

I left a few comments on the pull request, can you update it (squashing the commits), or maybe just do a new one?

comment:10 Changed 5 years ago by Aymeric Augustin <aymeric.augustin@…>

Resolution: fixed
Status: assignedclosed

In [875c76251710c9b643a4e6164b5570713fe024f5]:

Fixed #16916 -- Documented default headers for the test client.

Thanks sailorfred AT yahoo.com for the report and raulcd
for the initial version of the patch.

Note: See TracTickets for help on using tickets.
Back to Top