#NEWLINE# def parse_sections( lines ) : #NEWLINE# #INDENT# '\n    Parse pytest output and group lines per section (Errors, failures,\n    summary,etc.).\n\n    :param lines: pytest output segmented in lines\n\n    :returns: A dictionary where keys are section names and values are the\n        grouped line for the section.\n    ' #NEWLINE# section_types = { #NEWLINE# #INDENT# 'session' : re . compile ( '={2,} test session starts ={2,}' ) , #NEWLINE# 'errors' : re . compile ( '={2,} ERRORS ={2,}' ) , #NEWLINE# 'failures' : re . compile ( '={2,} FAILURES ={2,}' ) , #NEWLINE# 'summary' : re . compile ( '={2,} .* failed in .* seconds ={2,}' ) , #NEWLINE# #UNINDENT# } #NEWLINE# sections = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for lines in group_lines ( sections , '={2,} .* ={2,}' ) : #NEWLINE# #INDENT# for ( section_type , regex ) in section_types . iteritems ( ) : #NEWLINE# #INDENT# if regex . match ( lines [ 0 ] ) : #NEWLINE# #INDENT# sections [ section_type ] = lines #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return sections