Ticket #12878: 12878-2.diff
File 12878-2.diff, 2.8 KB (added by , 15 years ago) |
---|
-
django/forms/formsets.py
271 271 try: 272 272 self.clean() 273 273 except ValidationError, e: 274 self._non_form_errors = e.messages274 self._non_form_errors = self.error_class(e.messages) 275 275 276 276 def clean(self): 277 277 """ -
tests/regressiontests/admin_views/tests.py
11 11 from django.contrib.admin.sites import LOGIN_FORM_KEY 12 12 from django.contrib.admin.util import quote 13 13 from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME 14 from django.forms.util import ErrorList 14 15 from django.utils import formats 15 16 from django.utils.cache import get_max_age 16 17 from django.utils.html import escape … … 1028 1029 response = self.client.post('/test_admin/admin/admin_views/person/', data) 1029 1030 self.assertContains(response, "Grace is not a Zombie") 1030 1031 1032 def test_non_form_errors_is_errorlist(self): 1033 # test if non-form errors are correctly handled; ticket #12878 1034 data = { 1035 "form-TOTAL_FORMS": "1", 1036 "form-INITIAL_FORMS": "1", 1037 "form-MAX_NUM_FORMS": "0", 1038 1039 "form-0-id": "2", 1040 "form-0-alive": "1", 1041 "form-0-gender": "2", 1042 } 1043 response = self.client.post('/test_admin/admin/admin_views/person/', data) 1044 non_form_errors = response.context['cl'].formset.non_form_errors() 1045 self.assert_(isinstance(non_form_errors, ErrorList)) 1046 self.assertEqual(str(non_form_errors), str(ErrorList(["Grace is not a Zombie"]))) 1047 1031 1048 def test_list_editable_ordering(self): 1032 1049 collector = Collector.objects.create(id=1, name="Frederick Clegg") 1033 1050 -
tests/regressiontests/forms/formsets.py
621 621 >>> formset.management_form.prefix 622 622 'form' 623 623 624 # Regression test for #12878 ################################################# 625 626 >>> data = { 627 ... 'drinks-TOTAL_FORMS': '2', # the number of forms rendered 628 ... 'drinks-INITIAL_FORMS': '0', # the number of forms with initial data 629 ... 'drinks-MAX_NUM_FORMS': '0', # max number of forms 630 ... 'drinks-0-name': 'Gin and Tonic', 631 ... 'drinks-1-name': 'Gin and Tonic', 632 ... } 633 634 >>> formset = FavoriteDrinksFormSet(data, prefix='drinks') 635 >>> formset.is_valid() 636 False 637 >>> print formset.non_form_errors() 638 <ul class="errorlist"><li>You may only specify a drink once.</li></ul> 639 624 640 """