#NEWLINE# def test_limiting_max_forms( self ) : #NEWLINE# #INDENT# LimitedFavoriteDrinkFormSet = formset_factory ( FavoriteDrinkForm , extra = 3 ) #NEWLINE# formset = LimitedFavoriteDrinkFormSet ( ) #NEWLINE# form_output = [ ] #NEWLINE# for form in formset . forms : #NEWLINE# #INDENT# form_output . append ( str ( form ) ) #NEWLINE# #UNINDENT# self . assertHTMLEqual ( '\n' . join ( form_output ) , '<tr><th><label for="id_form-0-name">Name:</label></th><td><input type="text" name="form-0-name" id="id_form-0-name" /></td></tr>\n<tr><th><label for="id_form-1-name">Name:</label></th><td><input type="text" name="form-1-name" id="id_form-1-name" /></td></tr>\n<tr><th><label for="id_form-2-name">Name:</label></th><td><input type="text" name="form-2-name" id="id_form-2-name" /></td></tr>' ) #NEWLINE# LimitedFavoriteDrinkFormSet = formset_factory ( FavoriteDrinkForm , extra = 3 , max_num = 0 ) #NEWLINE# formset = LimitedFavoriteDrinkFormSet ( ) #NEWLINE# form_output = [ ] #NEWLINE# for form in formset . forms : #NEWLINE# #INDENT# form_output . append ( str ( formset ) ) #NEWLINE# #UNINDENT# self . assertEqual ( '\n' . join ( form_output ) , '' ) #NEWLINE# LimitedFavoriteDrinkFormSet = formset_factory ( FavoriteDrinkForm , extra = 5 , max_num = 2 ) #NEWLINE# formset = LimitedFavoriteDrinkFormSet ( ) #NEWLINE# form_output = [ ] #NEWLINE# for form in formset . forms : #NEWLINE# #INDENT# form_output . append ( str ( form ) ) #NEWLINE# #UNINDENT# self . assertHTMLEqual ( '\n' . join ( form_output ) , '<tr><th><label for="id_form-0-name">Name:</label></th><td><input type="text" name="form-0-name" id="id_form-0-name" /></td></tr>\n<tr><th><label for="id_form-1-name">Name:</label></th><td><input type="text" name="form-1-name" id="id_form-1-name" /></td></tr>' ) #NEWLINE# LimitedFavoriteDrinkFormSet = formset_factory ( FavoriteDrinkForm , extra = 1 , max_num = 2 ) #NEWLINE# formset = LimitedFavoriteDrinkFormSet ( ) #NEWLINE# form_output = [ ] #NEWLINE# for form in formset . forms : #NEWLINE# #INDENT# form_output . append ( str ( form ) ) #NEWLINE# #UNINDENT# self . assertHTMLEqual ( '\n' . join ( form_output ) , '<tr><th><label for="id_form-0-name">Name:</label></th><td><input type="text" name="form-0-name" id="id_form-0-name" /></td></tr>' )