Opened 5 years ago

Closed 4 days ago

#24782 closed New feature (wontfix)

Add TestCase.assertFormValid

Reported by: Marc Tamlyn Owned by: David Smith
Component: Testing framework Version: master
Severity: Normal Keywords: forms
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In the case the form is actually valid, then assertFormValid(form) is no different to assertTrue(form.is_valid), however when the assertion fails it should print some helpful output about which fields have validation errors and what those errors are. Even just outputting errors.as_json would help a lot. I've implemented code along the lines of this many times.

Change History (13)

comment:1 Changed 5 years ago by Simon Charette

Triage Stage: UnreviewedAccepted

comment:2 Changed 5 years ago by Luis Del Giudice

Owner: changed from nobody to Luis Del Giudice
Status: newassigned

comment:3 Changed 5 years ago by Tim Graham

Has patch: set
Needs documentation: set
Needs tests: set

comment:4 Changed 5 years ago by Tim Graham

Easy pickings: unset
Needs documentation: unset
Needs tests: unset
Patch needs improvement: set

See comment from Marc on the pull request for methods to be added.

comment:5 Changed 5 years ago by Joseph Victor Zammit

Owner: changed from Luis Del Giudice to Joseph Victor Zammit

comment:6 Changed 5 years ago by Joseph Victor Zammit

Patch needs improvement: unset

comment:7 Changed 5 years ago by Tim Graham

Patch needs improvement: set

Left comments for improvement.

comment:8 Changed 5 years ago by Joseph Victor Zammit

Patch needs improvement: unset

comment:9 Changed 5 years ago by Tim Graham

Patch needs improvement: set

There are comments on the new pull request for improvement.

comment:10 Changed 5 weeks ago by David Smith

Owner: changed from Joseph Victor Zammit to David Smith

comment:11 Changed 4 weeks ago by David Smith

Patch needs improvement: unset
Last edited 3 weeks ago by felixxm (previous) (diff)

comment:12 Changed 3 weeks ago by felixxm

Patch needs improvement: set

comment:13 Changed 4 days ago by felixxm

Resolution: wontfix
Status: assignedclosed
Triage Stage: AcceptedUnreviewed

After detailed analysis provided by David we decided to close this as wontfix:

  • expecting a user to pass in all the requirements to pass the ValidationError equality test is too hard to be useful,
  • the currently proposed code method isn't that robust, there may be too many caveats for it to be useful, e.g. custom user errors generated where passwords don't match are unlikely to have a code passed into the ValidationError,
  • if it's just pass/fail that isn't much benefit from self.assertIs(form.is_valid(), True),

In the end, this isn't worth adding extra functions.

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