#NEWLINE# def test_max_num( self ) : #NEWLINE# #INDENT# author1 = Author . objects . create ( name = 'Charles Baudelaire' ) #NEWLINE# author2 = Author . objects . create ( name = 'Paul Verlaine' ) #NEWLINE# author3 = Author . objects . create ( name = 'Walt Whitman' ) #NEWLINE# qs = Author . objects . order_by ( 'name' ) #NEWLINE# AuthorFormSet = modelformset_factory ( Author , max_num = None , extra = 3 ) #NEWLINE# formset = AuthorFormSet ( queryset = qs ) #NEWLINE# self . assertEqual ( len ( formset . forms ) , 6 ) #NEWLINE# self . assertEqual ( len ( formset . extra_forms ) , 3 ) #NEWLINE# AuthorFormSet = modelformset_factory ( Author , max_num = 4 , extra = 3 ) #NEWLINE# formset = AuthorFormSet ( queryset = qs ) #NEWLINE# self . assertEqual ( len ( formset . forms ) , 4 ) #NEWLINE# self . assertEqual ( len ( formset . extra_forms ) , 1 ) #NEWLINE# AuthorFormSet = modelformset_factory ( Author , max_num = 0 , extra = 3 ) #NEWLINE# formset = AuthorFormSet ( queryset = qs ) #NEWLINE# self . assertEqual ( len ( formset . forms ) , 3 ) #NEWLINE# self . assertEqual ( len ( formset . extra_forms ) , 0 ) #NEWLINE# AuthorFormSet = modelformset_factory ( Author , max_num = None ) #NEWLINE# formset = AuthorFormSet ( queryset = qs ) #NEWLINE# self . assertQuerysetEqual ( formset . get_queryset ( ) , [ '<Author: Charles Baudelaire>' , '<Author: Paul Verlaine>' , '<Author: Walt Whitman>' ] ) #NEWLINE# AuthorFormSet = modelformset_factory ( Author , max_num = 0 ) #NEWLINE# formset = AuthorFormSet ( queryset = qs ) #NEWLINE# self . assertQuerysetEqual ( formset . get_queryset ( ) , [ '<Author: Charles Baudelaire>' , '<Author: Paul Verlaine>' , '<Author: Walt Whitman>' ] ) #NEWLINE# AuthorFormSet = modelformset_factory ( Author , max_num = 4 ) #NEWLINE# formset = AuthorFormSet ( queryset = qs ) #NEWLINE# self . assertQuerysetEqual ( formset . get_queryset ( ) , [ '<Author: Charles Baudelaire>' , '<Author: Paul Verlaine>' , '<Author: Walt Whitman>' ] )