Opened 8 years ago
Closed 3 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 Changed 8 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 Changed 8 years ago by
Owner: | changed from nobody to Luis Del Giudice |
---|---|
Status: | new → assigned |
comment:3 Changed 8 years ago by
Has patch: | set |
---|---|
Needs documentation: | set |
Needs tests: | set |
comment:4 Changed 8 years ago by
Easy pickings: | unset |
---|---|
Needs documentation: | unset |
Needs tests: | unset |
Patch needs improvement: | set |
comment:5 Changed 8 years ago by
Owner: | changed from Luis Del Giudice to Joseph V Zammit |
---|
comment:6 Changed 8 years ago by
Patch needs improvement: | unset |
---|
I have opened a new PR: https://github.com/django/django/pull/5595
comment:8 Changed 8 years ago by
Patch needs improvement: | unset |
---|
comment:9 Changed 8 years ago by
Patch needs improvement: | set |
---|
There are comments on the new pull request for improvement.
comment:10 Changed 3 years ago by
Owner: | changed from Joseph V Zammit to David Smith |
---|
comment:11 Changed 3 years ago by
Patch needs improvement: | unset |
---|
comment:12 Changed 3 years ago by
Patch needs improvement: | set |
---|
comment:13 Changed 3 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
Triage Stage: | Accepted → Unreviewed |
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 theValidationError
, - 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.
See comment from Marc on the pull request for methods to be added.