#NEWLINE# def test_nullable_blankable_choices( self ) : #NEWLINE# #INDENT# choices = [ 'a' , 'b' , 'c' ] #NEWLINE# v = StringField ( null = True , null_prob = 0.3 , blank = True , blank_prob = 0.3 , choices = choices ) #NEWLINE# with mock . patch ( FIELDS_RANDOM_MODULE ) as mocked_random : #NEWLINE# #INDENT# mocked_random . random . return_value = 0 #NEWLINE# generated = v . generate ( ) #NEWLINE# self . assertIsNone ( generated ) #NEWLINE# #UNINDENT# with mock . patch ( FIELDS_RANDOM_MODULE ) as mocked_random : #NEWLINE# #INDENT# mocked_random . random . return_value = 0.5 #NEWLINE# mocked_random . choice = random . choice #NEWLINE# self . assertEqual ( v . generate ( ) , '' ) #NEWLINE# #UNINDENT# with mock . patch ( FIELDS_RANDOM_MODULE ) as mocked_random : #NEWLINE# #INDENT# mocked_random . random . return_value = 1 #NEWLINE# mocked_random . choice = random . choice #NEWLINE# self . assertIn ( v . generate ( ) , choices )