diff --git tests/forms_tests/tests/test_formsets.py tests/forms_tests/tests/test_formsets.py
index 0bd2811..b96c75e 100644
|
|
class FormsFormsetTestCase(SimpleTestCase):
|
461 | 461 | self.assertTrue(p.is_valid()) |
462 | 462 | self.assertEqual(len(p.deleted_forms), 1) |
463 | 463 | |
| 464 | def test_delete_fields_are_added_for_extra_formset_forms(self): |
| 465 | |
| 466 | """ |
| 467 | When a formset is built with can_delete=True and extra>=1, the extra |
| 468 | forms should be seen to hold DELETE fields. |
| 469 | """ |
| 470 | |
| 471 | class GenericForm(Form): |
| 472 | foo = CharField() |
| 473 | |
| 474 | GenericFormFormset = formset_factory( |
| 475 | form=GenericForm, |
| 476 | can_delete=True, |
| 477 | extra=2) |
| 478 | |
| 479 | # Instantiate formset and check DELETE fields exist |
| 480 | |
| 481 | formset = GenericFormFormset() |
| 482 | |
| 483 | self.assertEqual(len(formset), 2) |
| 484 | |
| 485 | self.assertIn('DELETE', formset.forms[0].fields) |
| 486 | self.assertIn('DELETE', formset.forms[1].fields) |
| 487 | |
| 488 | # Instantiate formset with existing data and check DELETE fields exist |
| 489 | |
| 490 | formset = GenericFormFormset(initial=[{'foo': 'bar'}]) |
| 491 | |
| 492 | self.assertEqual(len(formset), 3) |
| 493 | |
| 494 | self.assertIn('DELETE', formset.forms[0].fields) |
| 495 | self.assertIn('DELETE', formset.forms[1].fields) |
| 496 | self.assertIn('DELETE', formset.forms[2].fields) |
| 497 | |
464 | 498 | def test_formsets_with_ordering(self): |
465 | 499 | # FormSets with ordering ###################################################### |
466 | 500 | # We can also add ordering ability to a FormSet with an argument to |