Code

Ticket #10828: 10828-tests.diff

File 10828-tests.diff, 998 bytes (added by ramiro, 3 years ago)

Regression tests by Karen and copelco converted to unit test, demonstrates the issue is still present

Line 
1diff --git a/tests/regressiontests/forms/tests/formsets.py b/tests/regressiontests/forms/tests/formsets.py
2--- a/tests/regressiontests/forms/tests/formsets.py
3+++ b/tests/regressiontests/forms/tests/formsets.py
4@@ -381,6 +381,15 @@
5         formset = CheckFormSet(data, prefix='check')
6         self.assertTrue(formset.is_valid())
7 
8+        # Ticket 10828
9+        # The formset is valid (due to short circuiting forms marked for
10+        # deletion), but not all forms are valid:
11+        self.assertEqual([True, False, True], [form.is_valid() for form in formset.forms])
12+        try:
13+            [form.cleaned_data for form in formset.forms]
14+        except AttributeError, e:
15+            self.fail("Access to formset forms cleaned_data after deletion of forms fails even when formset.is_valid() returns True: %s" % e)
16+
17         # If we remove the deletion flag now we will have our validation back.
18         data['check-1-DELETE'] = ''
19         formset = CheckFormSet(data, prefix='check')