#NEWLINE# def validate( self , benchmarks ) : #NEWLINE# #INDENT# "\n        Execute the code once to get it's results (to be used in function validation). Compare the result to the\n        first function in the group.\n        :param benchmarks: list of benchmarks to validate.\n        " #NEWLINE# class_code = self . setup_src #NEWLINE# instance_creation = '\ninstance = {}' . format ( self . stmt ) #NEWLINE# for ( i , benchmark ) in enumerate ( benchmarks ) : #NEWLINE# #INDENT# if ( not benchmark . result_validation ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# validation_code = ( ( ( class_code + instance_creation ) + '\nvalidation_result = ' ) + benchmark . stmt ) #NEWLINE# validation_scope = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# exec ( validation_code , validation_scope ) #NEWLINE# if ( i == 0 ) : #NEWLINE# #INDENT# compare_against_function = benchmark [ 0 ] . callable . __name__ #NEWLINE# compare_against_result = validation_scope [ 'validation_result' ] #NEWLINE# logging . info ( 'PyPerform: Validating group "{b.group}" against method "{b.classname}.{b.callable.__name__}"' . format ( b = benchmarks [ 0 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( compare_against_result == validation_scope [ 'validation_result' ] ) : #NEWLINE# #INDENT# logging . info ( 'PyPerform: Validating {b.classname}.{b.callable.__name__}......PASSED!' . format ( b = benchmark ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# error = 'Results of functions {0} and {1} are not equivalent.\n{0}:\t {2}\n{1}:\t{3}' #NEWLINE# raise ValidationError ( error . format ( compare_against_function , benchmark . callable . __name__ , compare_against_result , validation_scope [ 'validation_result' ] ) )