#NEWLINE# def test_invalid_data( self ) : #NEWLINE# #INDENT# invalid_data_dicts = [ { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'This field is required.' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'This field is required.' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : [ ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'This field is required.' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : 'jane' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'The following usernames are incorrect: jane.' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : 'foo' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'The following usernames are incorrect: foo.' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : 'foo, bar' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'The following usernames are incorrect: (foo|bar), (foo|bar).' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : 'foo, john, bar' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'The following usernames are incorrect: (foo|bar), (foo|bar).' ] ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'users' : 'foo,    john  ' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'error' : ( 'users' , [ 'The following usernames are incorrect: foo.' ] ) , #NEWLINE# #UNINDENT# } ] #NEWLINE# for invalid_dict in invalid_data_dicts : #NEWLINE# #INDENT# form = CommaSeparatedTestForm ( data = invalid_dict [ 'data' ] ) #NEWLINE# self . assertFalse ( form . is_valid ( ) ) #NEWLINE# self . assertTrue ( re . match ( invalid_dict [ 'error' ] [ 1 ] [ 0 ] , form . errors [ invalid_dict [ 'error' ] [ 0 ] ] [ 0 ] ) )