#NEWLINE# def test_default( self ) : #NEWLINE# #INDENT# v = ArrayField ( IntegerField ( ) ) #NEWLINE# generated = v . generate ( ) #NEWLINE# self . assertTrue ( ( 1 <= len ( generated ) <= 10 ) ) #NEWLINE# self . assertTrue ( all ( [ isinstance ( i , int ) for i in i ] ) ) #NEWLINE# int_field = mock . Mock ( wraps = IntegerField ( ) ) #NEWLINE# int_field . generate = ( lambda : 0 ) #NEWLINE# str_field = mock . Mock ( wraps = StringField ( ) ) #NEWLINE# str_field . generate = ( lambda : 'string' ) #NEWLINE# v = ArrayField ( [ int_field , str_field ] ) #NEWLINE# with mock . patch ( FIELDS_RANDOM_MODULE ) as mocked_random : #NEWLINE# #INDENT# mocked_random . randint . return_value = 2 #NEWLINE# mocked_random . choice . side_effect = [ int_field , str_field ] #NEWLINE# generated = v . generate ( ) #NEWLINE# self . assertEqual ( len ( generated ) , 2 ) #NEWLINE# self . assertEqual ( generated [ 0 ] , 0 ) #NEWLINE# self . assertTrue ( generated [ 1 ] , 'string' )