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


Python junit_xml.TestSuite方法代码示例

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


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

示例1: handle_event

# 需要导入模块: import junit_xml [as 别名]
# 或者: from junit_xml import TestSuite [as 别名]
def handle_event(self, context: ExecutionContext, event: events.ExecutionEvent) -> None:
        if isinstance(event, events.Initialized):
            self.start_time = event.start_time
        if isinstance(event, events.AfterExecution):
            test_case = TestCase(
                f"{event.result.method} {event.result.path}",
                elapsed_sec=event.elapsed_time,
                allow_multiple_subelements=True,
            )
            if event.status == Status.failure:
                checks = get_unique_failures(event.result.checks)
                for idx, check in enumerate(checks, 1):
                    # `check.message` is always not empty for events with `failure` status
                    test_case.add_failure_info(message=f"{idx}. {check.message}")
            if event.status == Status.error:
                test_case.add_error_info(
                    message=event.result.errors[-1].exception, output=event.result.errors[-1].exception_with_traceback
                )
            self.test_cases.append(test_case)
        if isinstance(event, events.Finished):
            test_suites = [TestSuite("schemathesis", test_cases=self.test_cases, hostname=platform.node())]
            to_xml_report_file(file_descriptor=self.file_handle, test_suites=test_suites, prettyprint=True) 
开发者ID:kiwicom,项目名称:schemathesis,代码行数:24,代码来源:junitxml.py

示例2: get_junit_items

# 需要导入模块: import junit_xml [as 别名]
# 或者: from junit_xml import TestSuite [as 别名]
def get_junit_items(self, new_items=''):
        """
        Convert from canonical data model to junit test suit
        :param new_items:
        :return:
        """
        test_cases = []
        if not self.test_items and not new_items:
            raise ValueError('There it no test items')
        data = self.test_items if not new_items else new_items

        for item in data:
            tc = TestCase(item.issue, classname=item.confidence)
            message = ''
            for msg in item.msgs:
                message = message + msg.message + "\n\n"
            tc.add_error_info(message=message, error_type=item.severity)
            test_cases.append(tc)
        ts = TestSuite(self.report_name, test_cases)
        return ts 
开发者ID:dowjones,项目名称:reapsaw,代码行数:22,代码来源:Converter.py

示例3: main

# 需要导入模块: import junit_xml [as 别名]
# 或者: from junit_xml import TestSuite [as 别名]
def main() -> None:
    """Generate a JUnit XML file."""

    log = logparser.from_argv()

    toplevels = parse_log(log)
    testcases: typing.List[junit_xml.TestCase] = []
    for i, toplevel in enumerate(toplevels):
        testcases += toplevel_to_junit(i, toplevel)
    print(
        json.dumps(list(map(lambda x: f"{x.classname}", testcases)), indent=4),
        file=sys.stderr,
    )

    print(junit_xml.TestSuite.to_xml_string([junit_xml.TestSuite("tbot", testcases)])) 
开发者ID:Rahix,项目名称:tbot,代码行数:17,代码来源:junit.py

示例4: take_action

# 需要导入模块: import junit_xml [as 别名]
# 或者: from junit_xml import TestSuite [as 别名]
def take_action(self, args):
        test_cases = []
        if args.playbook is not None:
            playbooks = args.playbook
            results = (models.TaskResult().query
                       .join(models.Task)
                       .filter(models.TaskResult.task_id == models.Task.id)
                       .filter(models.Task.playbook_id.in_(playbooks)))
        else:
            results = models.TaskResult().query.all()

        for result in results:
            task_name = result.task.name
            if not task_name:
                task_name = result.task.action
            additional_results = {
                'host': result.host.name,
                'playbook_path': result.task.playbook.path
            }
            result_str = jsonutils.dumps(additional_results)
            test_path = \
                u'{playbook_file}.{play_name}'.format(
                    playbook_file=os.path.basename(result.task.playbook.path),
                    play_name=result.task.play.name)
            test_case = TestCase(
                name=task_name,
                classname=test_path,
                elapsed_sec=result.duration.seconds,
                stdout=result_str)
            if result.status == 'skipped':
                test_case.add_skipped_info(message=result.result)
            elif (result.status in ('failed', 'unreachable') and
                    result.ignore_errors is False):
                test_case.add_failure_info(message=result.result)
            test_cases.append(test_case)
        test_suite = TestSuite('Ansible Tasks', test_cases)

        # TODO: junit_xml doesn't order the TestCase parameters.
        # This makes it so the order of the parameters for the same exact
        # TestCase is not guaranteed to be the same and thus results in a
        # different stdout (or file). This is easily reproducible on Py3.
        xml_string = six.text_type(test_suite.to_xml_string([test_suite]))
        if args.output_file == '-':
            if six.PY2:
                sys.stdout.write(encodeutils.safe_encode(xml_string))
            else:
                sys.stdout.buffer.write(encodeutils.safe_encode(xml_string))
        else:
            with open(args.output_file, 'wb') as f:
                f.write(encodeutils.safe_encode(xml_string)) 
开发者ID:dmsimard,项目名称:ara-archive,代码行数:52,代码来源:generate.py


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