#NEWLINE# def test_xml_format_passfail( self ) : #NEWLINE# #INDENT# obj = JUnitXMLReporter ( ) #NEWLINE# obj . engine = EngineEmul ( ) #NEWLINE# obj . parameters = BetterDict ( ) #NEWLINE# pass_fail1 = PassFailStatus ( ) #NEWLINE# fc1_triggered = DataCriteria ( { #NEWLINE# #INDENT# 'stop' : True , #NEWLINE# 'label' : 'Sample 1 Triggered' , #NEWLINE# 'fail' : True , #NEWLINE# 'timeframe' : ( - 1 ) , #NEWLINE# 'threshold' : '150ms' , #NEWLINE# 'condition' : '<' , #NEWLINE# 'subject' : 'avg-rt' , #NEWLINE# #UNINDENT# } , pass_fail1 ) #NEWLINE# fc1_not_triggered = DataCriteria ( { #NEWLINE# #INDENT# 'stop' : True , #NEWLINE# 'label' : 'Sample 1 Not Triggered' , #NEWLINE# 'fail' : True , #NEWLINE# 'timeframe' : ( - 1 ) , #NEWLINE# 'threshold' : '300ms' , #NEWLINE# 'condition' : '>' , #NEWLINE# 'subject' : 'avg-rt' , #NEWLINE# #UNINDENT# } , pass_fail1 ) #NEWLINE# pass_fail2 = PassFailStatus ( ) #NEWLINE# fc2_triggered = DataCriteria ( { #NEWLINE# #INDENT# 'stop' : True , #NEWLINE# 'label' : 'Sample 2 Triggered' , #NEWLINE# 'fail' : True , #NEWLINE# 'timeframe' : ( - 1 ) , #NEWLINE# 'threshold' : '150ms' , #NEWLINE# 'condition' : '<=' , #NEWLINE# 'subject' : 'avg-rt' , #NEWLINE# #UNINDENT# } , pass_fail1 ) #NEWLINE# fc2_not_triggered = DataCriteria ( { #NEWLINE# #INDENT# 'stop' : True , #NEWLINE# 'label' : 'Sample 2 Not Triggered' , #NEWLINE# 'fail' : True , #NEWLINE# 'timeframe' : ( - 1 ) , #NEWLINE# 'threshold' : '300ms' , #NEWLINE# 'condition' : '=' , #NEWLINE# 'subject' : 'avg-rt' , #NEWLINE# #UNINDENT# } , pass_fail1 ) #NEWLINE# pass_fail1 . criterias . append ( fc1_triggered ) #NEWLINE# pass_fail1 . criterias . append ( fc1_not_triggered ) #NEWLINE# pass_fail2 . criterias . append ( fc2_triggered ) #NEWLINE# pass_fail2 . criterias . append ( fc1_not_triggered ) #NEWLINE# fc1_triggered . is_triggered = True #NEWLINE# fc2_triggered . is_triggered = True #NEWLINE# obj . engine . reporters . append ( pass_fail1 ) #NEWLINE# obj . engine . reporters . append ( pass_fail2 ) #NEWLINE# obj . engine . reporters . append ( BlazeMeterUploader ( ) ) #NEWLINE# path_from_config = tempfile . mktemp ( suffix = '.xml' , prefix = 'junit-xml_passfail' , dir = obj . engine . artifacts_dir ) #NEWLINE# obj . parameters . merge ( { #NEWLINE# #INDENT# 'filename' : path_from_config , #NEWLINE# 'data-source' : 'pass-fail' , #NEWLINE# #UNINDENT# } ) #NEWLINE# obj . prepare ( ) #NEWLINE# obj . last_second = DataPoint ( 0 ) #NEWLINE# obj . post_process ( ) #NEWLINE# with open ( obj . report_file_path , 'rb' ) as fds : #NEWLINE# #INDENT# f_contents = fds . read ( ) #NEWLINE# #UNINDENT# xml_tree = etree . fromstring ( f_contents ) #NEWLINE# self . assertEqual ( 'testsuite' , xml_tree . tag ) #NEWLINE# self . assertEqual ( 4 , len ( xml_tree . getchildren ( ) ) ) #NEWLINE# self . assertEqual ( 'testcase' , xml_tree . getchildren ( ) [ 0 ] . tag ) #NEWLINE# self . assertEqual ( 'error' , xml_tree . getchildren ( ) [ 0 ] . getchildren ( ) [ 0 ] . tag ) #NEWLINE# self . assertEqual ( 'error' , xml_tree . getchildren ( ) [ 2 ] . getchildren ( ) [ 0 ] . tag )