#NEWLINE# def test_choicefield_4( self ) : #NEWLINE# #INDENT# f = ChoiceField ( choices = [ ( 'Numbers' , ( ( '1' , 'One' ) , ( '2' , 'Two' ) ) ) , ( 'Letters' , ( ( '3' , 'A' ) , ( '4' , 'B' ) ) ) , ( '5' , 'Other' ) ] ) #NEWLINE# self . assertEqual ( '1' , f . clean ( 1 ) ) #NEWLINE# self . assertEqual ( '1' , f . clean ( '1' ) ) #NEWLINE# self . assertEqual ( '3' , f . clean ( 3 ) ) #NEWLINE# self . assertEqual ( '3' , f . clean ( '3' ) ) #NEWLINE# self . assertEqual ( '5' , f . clean ( 5 ) ) #NEWLINE# self . assertEqual ( '5' , f . clean ( '5' ) ) #NEWLINE# msg = "'Select a valid choice. 6 is not one of the available choices.'" #NEWLINE# with self . assertRaisesMessage ( ValidationError , f ) : #NEWLINE# #INDENT# f . clean ( '6' )