当前位置: 首页>>代码示例>>Python>>正文


Python Feedback.feedback_to_server方法代码示例

本文整理汇总了Python中feedback.Feedback.feedback_to_server方法的典型用法代码示例。如果您正苦于以下问题:Python Feedback.feedback_to_server方法的具体用法?Python Feedback.feedback_to_server怎么用?Python Feedback.feedback_to_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在feedback.Feedback的用法示例。


在下文中一共展示了Feedback.feedback_to_server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from feedback import Feedback [as 别名]
# 或者: from feedback.Feedback import feedback_to_server [as 别名]
class Runner:
    def __init__(self, args, task_id=None, xml_filename=None):
        parser = TestCaseParser()
        self.test_case_suites = parser.parse_from_csv(args)
        self.reporter = Reporter()
        self.feedback = Feedback(task_id)
        self.test_result = {}
        self.test_summary = {}

    def _store_csv_path(self, case_classify, csv_file_path):
        """Store the csv path into test_result dict.
        """
        if case_classify in self.test_result.keys():
            self.test_result[case_classify]['csv_file_path'] = csv_file_path

    def _store_result(self, case_classify, case_id, run_result, log_message, passed_num, failed_num, run_time):
        """Store result related information into test_result dict.
        """
        if run_result is True:
            run_result = 'Pass'
            passed_num += 1
        elif run_result == 'Error':
            run_result = 'Error'
            failed_num += 1
        else:
            run_result = 'Fail'
            failed_num += 1

        if case_classify not in self.test_result.keys():
            self.test_result[case_classify] = {}

        if 'result' not in self.test_result[case_classify].keys():
            self.test_result[case_classify]['result'] = {}

        self.test_result[case_classify]['result'].update({case_id: [str(run_result), log_message, str(run_time)]})
        logger.debug('Test Result: {0}'.format(str(run_result)))

        return passed_num, failed_num

    def _store_summary(self, case_classify, ran_cases, passed_cases, failed_cases, total_run_time):
        if case_classify in self.test_result.keys():
            self.test_result[case_classify]['summary'] = {
                                                            'ran_cases': ran_cases,
                                                            'passed_cases': passed_cases,
                                                            'failed_cases': failed_cases,
                                                            'total_run_time': total_run_time
                                                        }
        return True

    def _replace_attribue_with_vaiablespool(self, obj):
        from Engine.config import VariablesPool
        for key in VariablesPool.__dict__.keys():
            if not re.match(r'_{2}', key):
                setattr(obj, key, getattr(VariablesPool, key))

    def _invoke_test_case(self, case_id):
        '''
        :returns: the test result, the log message, the running time
        :rtype: string, string, string
        '''
        start_time = time.time()
        try:
            case_classify = case_id.split('_')[0]
            mod = __import__('TestCases.{0}.{0}'.format(case_classify), fromlist=[case_id])
            mod_class = getattr(mod, case_id)
            mod_class_inst = mod_class()
            self._replace_attribue_with_vaiablespool(mod_class_inst)
            run_result, log_message = getattr(mod_class_inst, 'run')()
            logger.debug('Run test case: {0}.{1}'.format(case_classify, case_id))
            end_time = time.time()
            run_time = end_time - start_time
            result = (run_result, log_message, int(run_time))

        except:
            test_result = False
            logger.error('[RUN] TestCases.{0}.{1}'.format(case_classify, case_id))
            logger.error(traceback.format_exc())
            end_time = time.time()
            run_time = end_time - start_time
            result = ('Error', str(traceback.format_exc()), int(run_time))

        return result[0], result[1], result[2]

    def run_all(self):
        self.run('.*')

    def run(self, spec_case_id):
        run_count = 0
        passed_num = 0
        failed_num = 0
        spec_case_id = '\w' if spec_case_id == '' else spec_case_id
        self.feedback.feedback_to_server(self.test_result)  # this can initial feedback server.

        if self.test_case_suites is False:
            return
        for case_classify in self.test_case_suites.keys():
            if case_classify is None:
                logger.error('Found a None case_classify!')
                continue

#.........这里部分代码省略.........
开发者ID:dkentw,项目名称:pi-tester,代码行数:103,代码来源:TestEngine.py


注:本文中的feedback.Feedback.feedback_to_server方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。