summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2011-01-08 14:50:31 +0000
committerAndrew Godwin <andrew@aeracode.org>2011-01-08 14:50:31 +0000
commit34d306c71c2c30d8543ab65934d351b86f3de008 (patch)
tree301c50be77c7994993fae4f844fead8c230883f2
parent2b90267fa827439a29cb016b8548aec23f3b07c2 (diff)
Fixed #12295 -- Issue had already been fixed, but added test. Thanks tomevans222 and dpn.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15159 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/regressiontests/forms/tests/formsets.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests/formsets.py b/tests/regressiontests/forms/tests/formsets.py
index db947973e4..ad622f360f 100644
--- a/tests/regressiontests/forms/tests/formsets.py
+++ b/tests/regressiontests/forms/tests/formsets.py
@@ -29,6 +29,11 @@ class BaseFavoriteDrinksFormSet(BaseFormSet):
seen_drinks.append(drink['name'])
+class EmptyFsetWontValidate(BaseFormSet):
+ def clean(self):
+ raise ValidationError("Clean method called")
+
+
# Let's define a FormSet that takes a list of favorite drinks, but raises an
# error if there are any duplicates. Used in ``test_clean_hook``,
# ``test_regression_6926`` & ``test_regression_12878``.
@@ -761,3 +766,13 @@ class FormsFormsetTestCase(TestCase):
formset = FavoriteDrinksFormSet(data, prefix='drinks')
self.assertFalse(formset.is_valid())
self.assertEqual(formset.non_form_errors(), [u'You may only specify a drink once.'])
+
+class TestEmptyFormSet(TestCase):
+ "Test that an empty formset still calls clean()"
+ def test_empty_formset_is_valid(self):
+ EmptyFsetWontValidateFormset = formset_factory(FavoriteDrinkForm, extra=0, formset=EmptyFsetWontValidate)
+ formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'0'},prefix="form")
+ formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'1', 'form-0-name':'bah' },prefix="form")
+ self.assertFalse(formset.is_valid())
+ self.assertFalse(formset2.is_valid())
+