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


Python TestSuite.to_file方法代码示例

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


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

示例1: write_xml_file

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def write_xml_file(self):
    test_cases = []
    if os.path.isfile(self.output):
      logging.warn("File exists,deleting...")
      os.remove(self.output)
    with open(self.output,'a') as f:
      for _, elements in self.log.items():
        for j in elements.viewitems():
          if j[0] == 'date' or j[0] == 'profile' or j[0] == 'score':
            # we really don't care
            pass
          else:
            try:
              test_case = TestCase(j[0], j[1]['descr'], '', '', '')
              if j[1]['status'] == 'Fail':
                test_case.add_failure_info(j[1]['output'])
              else:
                test_case = TestCase(j[0], '', '', '', '')
              test_cases.append(test_case)
            except KeyError:
              # the world's smallest violin playin' for KeyError
              pass
      ts = [TestSuite("Docker Security Benchmarks", test_cases)]
      TestSuite.to_file(f, ts) 
开发者ID:zuBux,项目名称:drydock,代码行数:26,代码来源:output.py

示例2: generate

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def generate(self):
    """
    Generates the report
    """
    self._setup()
    for config_name in self.report_info.config_to_test_names_map.keys():
      config_dir = os.path.join(self.report_info.resource_dir, config_name)
      utils.makedirs(config_dir)
      testsuite = self._generate_junit_xml(config_name)
      with open(os.path.join(self.report_info.junit_xml_path, 'zopkio_junit_reports.xml'), 'w') as file:
          TestSuite.to_file(file, [testsuite], prettyprint=False) 
开发者ID:linkedin,项目名称:Zopkio,代码行数:13,代码来源:junit_reporter.py

示例3: teardown

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def teardown(self):
        if len(self.failed_test):
            test_cases = self.failed_test
        else:
            test_cases = list()
            test_cases.append(TestCase(name='Fuzz test succeed', status='Pass'))
        if self.junit_report_path:
            with open(self.junit_report_path, 'w') as report_file:
                TestSuite.to_file(report_file, [TestSuite("API Fuzzer", test_cases)], prettyprint=True)
        super(ServerTarget, self).teardown() 
开发者ID:KissPeter,项目名称:APIFuzzer,代码行数:12,代码来源:fuzz_request_sender.py

示例4: file_junit_report

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def file_junit_report(rules, report):
    """
    Output file Junit xml report

    :param rules: set of rules to verify
    :param report: report generated by drheader
    :return: None
    """

    test_cases = []

    for header in rules:
        tc = []
        for item in report:
            if item.get('rule') == header:
                violation = item.copy()
                violation.pop('rule')
                message = violation.pop('message')
                tc = TestCase(name=header + ' :: ' + message)
                tc.add_failure_info(message, violation)
                test_cases.append(tc)
        if not tc:
            tc = TestCase(name=header)
            test_cases.append(tc)

    os.makedirs('reports', exist_ok=True)
    with open('reports/junit.xml', 'w') as f:
        TestSuite.to_file(f, [TestSuite(name='DrHeader', test_cases=test_cases)], prettyprint=False)
        f.close() 
开发者ID:Santandersecurityresearch,项目名称:DrHeader,代码行数:31,代码来源:cli_utils.py

示例5: write_junit_xml

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def write_junit_xml(testname, filename, test_cases):
  with open(filename, 'w') as f:
    ts = TestSuite(testname, test_cases)
    TestSuite.to_file(f, [ts], prettyprint=False)

# Bash utilities 
开发者ID:kubeflow,项目名称:pipelines,代码行数:8,代码来源:utils.py

示例6: generate_reports

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def generate_reports(args, models):
    """
    Generate Report Portal, JUnit, JSON reports
    :param args: argparse.Namespace
        commandline arguments
    :param models: dict of BaseReport
    """
    repo = os.environ.get('REPO', '')
    branch = os.environ.get('BRANCH', 'develop')
    if repo.endswith('.git'):
        repo = repo[:-len('.git')]
    canonical = Converter(models, repo, branch)
    ti = canonical.get_rp_items()

    if ti:
        if args.reportportal:
            send_items_to_rp(ti)

        junit_items = canonical.get_junit_items()
        if os.path.exists(os.path.dirname(args.output)):
            if junit_items:
                with open(args.output, 'w') as f:
                    TestSuite.to_file(f, [junit_items], prettyprint=False)
        if os.path.exists(os.path.dirname(args.json_output)):
            json_items = canonical.get_json_items()
            if json_items:
                with open(args.json_output, 'w') as f:
                    json.dump(json_items, f, indent=4, sort_keys=True)
    else:
        logger.critical('There are no findings in report.') 
开发者ID:dowjones,项目名称:reapsaw,代码行数:32,代码来源:generate_reports.py

示例7: write_test_results

# 需要导入模块: from junit_xml import TestSuite [as 别名]
# 或者: from junit_xml.TestSuite import to_file [as 别名]
def write_test_results(results, endpoints, args):
    if args.output.endswith(".xml"):
        formatted = format_test_results(results, endpoints, "junit", args)
    else:
        formatted = format_test_results(results, endpoints, "json", args)
    with open(args.output, "w") as f:
        if args.output.endswith(".xml"):
            # pretty-print to help out Jenkins (and us humans), which struggles otherwise
            TestSuite.to_file(f, [formatted], prettyprint=True)
        else:
            f.write(formatted)
        print(" * Test results written to file: {}".format(args.output))
    return identify_exit_code(results, args) 
开发者ID:AMWA-TV,项目名称:nmos-testing,代码行数:15,代码来源:NMOSTesting.py


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