Example #1
0
 def moreProcess_report(self):
     """多进程执行用例并输出报告"""
     log.info('start moreProcess!')
     pros = []
     q = mp.Queue(maxsize=len(self.caselist))
     for i in self.suite_all:
         pro = Process(target=self.process_run_Beautifuhtml,
                       args=(i, q, True))
         pros.append(pro)
     for pro in pros:
         pro.start()
     for pro in pros:
         self.report_result.append(q.get())
         # time.sleep(1)
         # print(self.report_result)
         # pro.join()
         # try:
         #     self.report_result.append(q.get_nowait())
         #     print(self.report_result)
         #     pro.join()
         # except _queue.Empty as queue:
         #     log.error('异常,_queue.Empty:"{0}"'.format(queue))
         #     pro.terminate()
         #     raise
     dict = {}
     log.info('start data processing!')
     for i in range(len(self.report_result)):
         if i == 0:
             dict['testName'] = self.report_result[0]['testName']
             dict['beginTime'] = self.report_result[0]['beginTime']
             dict['testPass'] = self.report_result[i]['testPass']
             dict['testResult'] = self.report_result[i]['testResult']
             dict['testAll'] = self.report_result[i]['testAll']
             dict['testFail'] = self.report_result[i]['testFail']
             dict['testSkip'] = self.report_result[i]['testSkip']
             dict['testError'] = self.report_result[i]['testError']
         else:
             dict['testPass'] += self.report_result[i]['testPass']
             dict['testResult'] += self.report_result[i]['testResult']
             dict['testAll'] += self.report_result[i]['testAll']
             dict['testFail'] += self.report_result[i]['testFail']
             dict['testSkip'] += self.report_result[i]['testSkip']
             dict['testError'] += self.report_result[i]['testError']
         dict['totalTime'] = self.report_result[i]['totalTime']
     log.info('MoreProcess end.start Transfer data and generate reports...')
     result = BeautifulReport(self.suite_all)
     result.stop_output(log_path=self.reportFile1 + '\\', FIELDS=dict)
     log.info('End of the project.Please see the report!')
Example #2
0
 def pool_report(self):
     """使用进程池执行用例并输出报告"""
     log.info('start pool!')
     q = mp.Manager().Queue()
     pool = mp.Pool()
     for i in self.suite_all:
         pool.apply_async(self.pool_run_Beautifuhtml, args=(i, q, True))
     pool.close()
     pool.join()
     for i in range(q.qsize()):
         self.report_result.append(q.get())
     dict = {}
     log.info('start data processing!')
     for i in range(len(self.report_result)):
         if i == 0:
             dict['testName'] = self.report_result[0]['testName']
             dict['beginTime'] = self.report_result[0]['beginTime']
             dict['testPass'] = self.report_result[i]['testPass']
             dict['testResult'] = self.report_result[i]['testResult']
             dict['testAll'] = self.report_result[i]['testAll']
             dict['testFail'] = self.report_result[i]['testFail']
             dict['testSkip'] = self.report_result[i]['testSkip']
             dict['testError'] = self.report_result[i]['testError']
         else:
             dict['testPass'] += self.report_result[i]['testPass']
             dict['testResult'] += self.report_result[i]['testResult']
             dict['testAll'] += self.report_result[i]['testAll']
             dict['testFail'] += self.report_result[i]['testFail']
             dict['testSkip'] += self.report_result[i]['testSkip']
             dict['testError'] += self.report_result[i]['testError']
         dict['totalTime'] = self.report_result[i]['totalTime']
     log.info('MoreProcess end.start Transfer data and generate reports...')
     result = BeautifulReport(self.suite_all)
     slash = '/' if platform.system(
     ) != 'Windows' else '//'  # 判断系统,给出不同路径连接符
     result.stop_output(log_path=self.reportFile1 + slash, FIELDS=dict)
     log.info('End of the project.Please see the report!')
     print('用例结束,在{0}查看报告!'.format(self.reportFile1))