Code

Opened 6 years ago

Closed 6 years ago

#6521 closed (wontfix)

add a "name" parameter to test client get() and post() methods

Reported by: Will Hardy Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Allow named url patterns to be entered directly into the test client's get() and post() methods for the sake of readability and to encourage use of named url paths.
For example, instead of:

        url = reverse('poll_edit', args=(24,))
        response = client.get(url)

It would become:

        response = client.get(name='poll_edit', args=(24,))

This may of course conflict with the direct passing of extra header information to get() and post()

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by Will Hardy

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I can write the tests and a patch if people think this idea is worthwhile.

comment:2 Changed 6 years ago by SmileyChris

  • Component changed from Uncategorized to Unit test system
  • Triage Stage changed from Unreviewed to Design decision needed

Interesting idea

comment:3 Changed 6 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

I'm afraid I don't see the benefit here. client.get() has a very clear and obvious API - it takes a URL. reverse() has a very clear and obvious API - it takes a name, and turns it into a URL. This change would require you to munge the API of client.get() and add a whole lot of messy error checking just so you can avoid typing 4 characters. This seems like a false economy to me.

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.