Opened 9 years ago

Closed 4 years ago

#24782 closed New feature (wontfix)

Add TestCase.assertFormValid

Reported by: Marc Tamlyn Owned by: David Smith
Component: Testing framework Version: dev
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 by Simon Charette, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Luis Del Giudice, 9 years ago

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

comment:3 by Tim Graham, 9 years ago

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

comment:4 by Tim Graham, 9 years ago

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 by Joseph V Zammit, 9 years ago

Owner: changed from Luis Del Giudice to Joseph V Zammit

comment:6 by Joseph V Zammit, 9 years ago

Patch needs improvement: unset

comment:7 by Tim Graham, 9 years ago

Patch needs improvement: set

Left comments for improvement.

comment:8 by Joseph V Zammit, 9 years ago

Patch needs improvement: unset

comment:9 by Tim Graham, 9 years ago

Patch needs improvement: set

There are comments on the new pull request for improvement.

comment:10 by David Smith, 4 years ago

Owner: changed from Joseph V Zammit to David Smith

comment:11 by David Smith, 4 years ago

Patch needs improvement: unset
Last edited 4 years ago by Mariusz Felisiak (previous) (diff)

comment:12 by Mariusz Felisiak, 4 years ago

Patch needs improvement: set

comment:13 by Mariusz Felisiak, 4 years ago

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