#NEWLINE# def write_results( f , top_element ) : #NEWLINE# #INDENT# cases = top_element . getElementsByTagName ( 'testcase' ) #NEWLINE# sorted_cases = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for case in cases : #NEWLINE# #INDENT# class_name = case . getAttribute ( 'classname' ) #NEWLINE# if ( class_name in sorted_cases ) : #NEWLINE# #INDENT# sorted_cases [ class_name ] . append ( case ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sorted_cases [ test_case ] = [ case ] #NEWLINE# #UNINDENT# #UNINDENT# class_names = sorted_cases . keys ( ) #NEWLINE# f . write ( '<tr>' ) #NEWLINE# f . write ( '<th align="left">Test class</th><th align="left">Test case</th><th align="left">Result</th><th align="left">Time</th>' ) #NEWLINE# f . write ( '</tr>' ) #NEWLINE# for class_name in class_names : #NEWLINE# #INDENT# test_case = sorted_cases [ class_name ] #NEWLINE# f . write ( '<tr>\n' ) #NEWLINE# f . write ( '<td>{0}</td>\n' . format ( class_name ) ) #NEWLINE# for case in test_case : #NEWLINE# #INDENT# f . write ( '<tr>\n' ) #NEWLINE# failure = case . getElementsByTagName ( 'failure' ) #NEWLINE# error = case . getElementsByTagName ( 'error' ) #NEWLINE# if ( len ( error ) > 0 ) : #NEWLINE# #INDENT# f . write ( '<td></td><td>{0}</td><td>Error</td><td>{1}</td>\n' . format ( case . getAttribute ( 'name' ) , case . getAttribute ( 'time' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( failure ) > 0 ) : #NEWLINE# #INDENT# f . write ( '<td></td><td>{0}</td><td>Failure</td><td>{1}</td>\n' . format ( case . getAttribute ( 'name' ) , case . getAttribute ( 'time' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# f . write ( '<td></td><td>{0}</td><td>Ok</td><td>{1}</td>\n' . format ( case . getAttribute ( 'name' ) , case . getAttribute ( 'time' ) ) )