[Django] #24782: Add TestCase.assertFormValid

19 views
Skip to first unread message

Django

unread,
May 11, 2015, 10:47:21 AM5/11/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
---------------------------------------------+------------------------
Reporter: mjtamlyn | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Keywords: forms
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
---------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24782>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 11, 2015, 10:59:20 AM5/11/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+------------------------------------

Reporter: mjtamlyn | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by charettes):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:1>

Django

unread,
May 11, 2015, 4:40:38 PM5/11/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: mjtamlyn | Owner: delgiudices
Type: New feature | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by delgiudices):

* owner: nobody => delgiudices
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:2>

Django

unread,
May 13, 2015, 8:35:19 AM5/13/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: mjtamlyn | Owner: delgiudices
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by timgraham):

* needs_docs: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:3>

Django

unread,
Jul 3, 2015, 11:54:47 AM7/3/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: mjtamlyn | Owner: delgiudices
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1
* needs_tests: 1 => 0
* easy: 1 => 0
* needs_docs: 1 => 0


Comment:

See [https://github.com/django/django/pull/4645#issuecomment-107254019
comment from Marc on the pull request] for methods to be added.

--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:4>

Django

unread,
Nov 7, 2015, 5:29:01 AM11/7/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+------------------------------------
Reporter: mjtamlyn | Owner: jvzammit

Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by jvzammit):

* owner: delgiudices => jvzammit


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:5>

Django

unread,
Nov 7, 2015, 10:27:06 AM11/7/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+------------------------------------
Reporter: mjtamlyn | Owner: jvzammit
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by jvzammit):

* needs_better_patch: 1 => 0


Comment:

I have opened a new PR: https://github.com/django/django/pull/5595

--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:6>

Django

unread,
Nov 19, 2015, 3:42:53 PM11/19/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+------------------------------------
Reporter: mjtamlyn | Owner: jvzammit
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

Left comments for improvement.

--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:7>

Django

unread,
Dec 26, 2015, 4:11:41 PM12/26/15
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+------------------------------------
Reporter: mjtamlyn | Owner: jvzammit
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by jvzammit):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:8>

Django

unread,
Feb 2, 2016, 5:57:46 PM2/2/16
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+------------------------------------
Reporter: mjtamlyn | Owner: jvzammit
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

There are comments on [https://github.com/django/django/pull/6046 the new
pull request] for improvement.

--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:9>

Django

unread,
Jul 8, 2020, 1:46:34 AM7/8/20
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: Marc Tamlyn | Owner: David Smith

Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by David Smith):

* owner: Joseph Victor Zammit => David Smith


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:10>

Django

unread,
Jul 10, 2020, 4:30:02 PM7/10/20
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: Marc Tamlyn | Owner: David Smith
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by David Smith):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:11>

Django

unread,
Jul 20, 2020, 6:12:40 AM7/20/20
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: Marc Tamlyn | Owner: David Smith
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: forms | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:12>

Django

unread,
Aug 4, 2020, 6:27:06 AM8/4/20
to django-...@googlegroups.com
#24782: Add TestCase.assertFormValid
-----------------------------------+---------------------------------------
Reporter: Marc Tamlyn | Owner: David Smith
Type: New feature | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: wontfix

Keywords: forms | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+---------------------------------------
Changes (by felixxm):

* status: assigned => closed
* resolution: => wontfix
* stage: Accepted => Unreviewed


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24782#comment:13>

Reply all
Reply to author
Forward
0 new messages