diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py
index 0739a6b..50daac7 100644
a
|
b
|
class ModelFormsetTest(TestCase):
|
427 | 427 | '<Author: Walt Whitman>', |
428 | 428 | ]) |
429 | 429 | |
| 430 | def test_max_num_prevent_instance_creation(self): |
| 431 | Author.objects.create(name='Charles Baudelaire') |
| 432 | AuthorFormSet = modelformset_factory(Author, fields="__all__", max_num=1, extra=0, validate_max=True) |
| 433 | data = { |
| 434 | 'form-TOTAL_FORMS': '1', |
| 435 | 'form-INITIAL_FORMS': '0', # Would be 1 normally, but pretend the user edited it. |
| 436 | 'form-MAX_NUM_FORMS': '0', |
| 437 | 'form-0-name': 'Walt Whitman', |
| 438 | } |
| 439 | formset = AuthorFormSet(data, queryset=Author.objects.all()) |
| 440 | self.assertTrue(formset.is_valid()) |
| 441 | formset.save() |
| 442 | self.assertQuerysetEqual(Author.objects.all(), [ |
| 443 | '<Author: Charles Baudelaire>', |
| 444 | '<Author: Walt Whitman>', |
| 445 | ]) |
| 446 | |
430 | 447 | def test_min_num(self): |
431 | 448 | # Test the behavior of min_num with model formsets. It should be |
432 | 449 | # added to extra. |