Code

Opened 3 years ago

Closed 23 months ago

#16916 closed Cleanup/optimization (fixed)

Please document django.test.Client.defaults

Reported by: sailorfred@… Owned by: raulcd
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: raulcd 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 aaugustin)

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 raulcd 3 years ago.
First patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 3 years ago by aaugustin

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Please document django.test.Class.defaults to Please document django.test.Client.defaults
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/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 3 years ago by russellm

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 3 years ago by raulcd

  • Cc raulcd added
  • Owner changed from nobody to raulcd

comment:4 Changed 3 years ago by raulcd

  • Status changed from new to assigned

comment:5 Changed 3 years ago by raulcd

  • 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 3 years ago by raulcd

First patch

comment:6 Changed 2 years ago by krzysiumed

  • 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 23 months 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 23 months ago by aaugustin

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 23 months ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.