summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2011-09-10 00:05:48 +0000
committerKaren Tracey <kmtracey@gmail.com>2011-09-10 00:05:48 +0000
commite061b036a54597b6a994573ea6aa2ee02ca8838e (patch)
treed06938f2d2ad65118262562776b9aa4eb58a45ac /tests/regressiontests/forms
parent7bca049f1c620cb7e595745607257c774b6c0b2e (diff)
Fixed #15722: ensure formsets evaluate to True even if they have no forms. Thanks mlavin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16756 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms')
-rw-r--r--tests/regressiontests/forms/tests/formsets.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests/formsets.py b/tests/regressiontests/forms/tests/formsets.py
index 4451fc76b1..869b6e35a6 100644
--- a/tests/regressiontests/forms/tests/formsets.py
+++ b/tests/regressiontests/forms/tests/formsets.py
@@ -805,6 +805,17 @@ class FormsFormsetTestCase(TestCase):
self.assertEqual(str(reverse_formset[1]), str(forms[-2]))
self.assertEqual(len(reverse_formset), len(forms))
+ def test_formset_nonzero(self):
+ """
+ Formsets with no forms should still evaluate as true.
+ Regression test for #15722
+ """
+ ChoiceFormset = formset_factory(Choice, extra=0)
+ formset = ChoiceFormset()
+ self.assertEqual(len(formset.forms), 0)
+ self.assertTrue(formset)
+
+
data = {
'choices-TOTAL_FORMS': '1', # the number of forms rendered
'choices-INITIAL_FORMS': '0', # the number of forms with initial data