#NEWLINE# def test_it_validates_formats_if_a_checker_is_provided( self ) : #NEWLINE# #INDENT# checker = mock . Mock ( spec = FormatChecker ) #NEWLINE# validator = self . validator_class ( { #NEWLINE# #INDENT# 'format' : 'foo' , #NEWLINE# #UNINDENT# } , format_checker = checker ) #NEWLINE# validator . validate ( 'bar' ) #NEWLINE# checker . check . assert_called_once_with ( 'bar' , 'foo' ) #NEWLINE# cause = ValueError ( ) #NEWLINE# checker . check . side_effect = FormatError ( 'aoeu' , cause = cause ) #NEWLINE# with self . assertRaises ( ValidationError ) as cm : #NEWLINE# #INDENT# validator . validate ( 'bar' ) #NEWLINE# #UNINDENT# self . assertIs ( cm . exception . cause , cause )