Re: [Django] #35723: Change django.forms.formsets.all_valid() to use generator instead of list comprehension (was: formset all_valid use generator comprehension instead of list comprehension)

5 views
Skip to first unread message

Django

unread,
Aug 31, 2024, 5:56:16 AM8/31/24
to django-...@googlegroups.com
#35723: Change django.forms.formsets.all_valid() to use generator instead of list
comprehension
-------------------------------------+-------------------------------------
Reporter: Prashant Rana | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Forms | Version: dev
Severity: Normal | Resolution: invalid
Keywords: formsets, | Triage Stage:
validation | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* resolution: => invalid
* status: new => closed
* summary:
formset all_valid use generator comprehension instead of list
comprehension
=>
Change django.forms.formsets.all_valid() to use generator instead of
list comprehension

Comment:

That would make the behavior not match the docstring ("Validate every
formset") and it causes a test failure:
{{{
======================================================================
FAIL: test_invalid
(forms_tests.tests.test_formsets.AllValidTests.test_invalid)
all_valid() validates all forms, even when some are invalid.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/tests/forms_tests/tests/test_formsets.py",
line 1962, in test_invalid
self.assertEqual(formset2._errors, expected_errors)
AssertionError: None != [{'votes': ['This field is required.']}, {'votes':
['This field is required.']}]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35723#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages