How to use the junitparser.JUnitXml function in junitparser

To help you get started, we’ve selected a few junitparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / watson-assistant-workbench / scripts / functions_test_evaluate.py View on Github external
except IOError:
            logger.critical("Cannot open evaluation JUnit XML output file '%s'", junitFileName)
            sys.exit(1)

    try:
        inputJson = json.load(inputFile)
    except ValueError as e:
        logger.critical("Cannot decode json from test output file '%s', error '%s'", args.inputFileName, str(e))
        sys.exit(1)

    if not isinstance(inputJson, list):
        logger.critical("Test output json is not array!")
        sys.exit(1)

    # run evaluation
    xml = JUnitXml()
    suite = TestSuite(os.path.splitext(os.path.basename(args.inputFileName))[0]) # once we support multiple test files then for each one should be test suite created
    xml.add_testsuite(suite)
    suite.timestamp = str(datetime.datetime.now()) # time of evaluation, not the testing it self (evaluations could differ)
    #suite.hostname = ''
    testCounter = 0
    for test in inputJson:
        case = TestCase()
        suite.add_testcase(case)

        if not isinstance(test, dict):
            errorMessage = "Input test array element {:d} is not dictionary. Each test has to be dictionary, please see doc!".format(testCounter)
            logger.error(errorMessage)
            case.result = Error(errorMessage, 'ValueError')
            continue

        logger.info("Test number %d, name '%s'", testCounter, test.get('name', '-'))
github DonJayamanne / pythonVSCode / uitests / uitests / __main__.py View on Github external
def _update_junit_report(destination, **kwargs):
    """Updates the junit reports to contain the names of the current Azdo Job."""
    destination = os.path.abspath(destination)
    report_dir = os.path.join(destination, "reports")
    report_name = os.getenv("AgentJobName", "")
    for name in glob.glob(os.path.join(report_dir, "*.xml")):
        xml = JUnitXml.fromfile(name)
        xml.name = f"({report_name}): {xml.name}"
        for suite in xml:
            suite.classname = f"({report_name}): {suite.classname}"
        xml.write()
github aws / aws-parallelcluster / tests / integration-tests / reports_generator.py View on Github external
def generate_junitxml_merged_report(test_results_dir):
    """
    Merge all junitxml generated reports in a single one.
    :param test_results_dir: output dir containing the junitxml reports to merge.
    """
    merged_xml = None
    for dir, _, files in os.walk(test_results_dir):
        for file in files:
            if file.endswith("results.xml"):
                if not merged_xml:
                    merged_xml = JUnitXml.fromfile(os.path.join(dir, file))
                else:
                    merged_xml += JUnitXml.fromfile(os.path.join(dir, file))

    merged_xml.write("{0}/test_report.xml".format(test_results_dir), pretty=True)
github tytso / xfstests-bld / kvm-xfstests / test-appliance / files / usr / lib / python2.7 / gen_results_summary.py View on Github external
def gen_results_summary(results_dir, output_fn=None, merge_fn=None,
                        verbose=False):
    """Scan a results directory and generate a summary file"""
    reports = []
    combined = JUnitXml()
    nr_files = 0
    out_f = sys.stdout

    for filename in get_results(results_dir):
        reports.append(JUnitXml.fromfile(filename))

    if len(reports) == 0:
        return 0

    if output_fn is not None:
        out_f = open(output_fn, "w")

    props = copy.deepcopy(reports[0].child(Properties))

    ltm = check_for_ltm(results_dir, props)

    print_header(out_f, props)

    sort_by = lambda ts: parse_timestamp(ts.timestamp)
    if ltm:
        sort_by = lambda ts: ts.hostname
github aws / aws-parallelcluster / tests / integration-tests / reports_generator.py View on Github external
def generate_junitxml_merged_report(test_results_dir):
    """
    Merge all junitxml generated reports in a single one.
    :param test_results_dir: output dir containing the junitxml reports to merge.
    """
    merged_xml = None
    for dir, _, files in os.walk(test_results_dir):
        for file in files:
            if file.endswith("results.xml"):
                if not merged_xml:
                    merged_xml = JUnitXml.fromfile(os.path.join(dir, file))
                else:
                    merged_xml += JUnitXml.fromfile(os.path.join(dir, file))

    merged_xml.write("{0}/test_report.xml".format(test_results_dir), pretty=True)
github tytso / xfstests-bld / kvm-xfstests / test-appliance / files / usr / lib / python2.7 / gen_results_summary.py View on Github external
def gen_results_summary(results_dir, output_fn=None, merge_fn=None,
                        verbose=False):
    """Scan a results directory and generate a summary file"""
    reports = []
    combined = JUnitXml()
    nr_files = 0
    out_f = sys.stdout

    for filename in get_results(results_dir):
        reports.append(JUnitXml.fromfile(filename))

    if len(reports) == 0:
        return 0

    if output_fn is not None:
        out_f = open(output_fn, "w")

    props = copy.deepcopy(reports[0].child(Properties))

    ltm = check_for_ltm(results_dir, props)
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
if args.status and args.sha != None and args.repo and gh:
        set_status(gh, args.repo, args.sha)
        sys.exit(0)

    if not args.commits:
        sys.exit(1)

    suite = TestSuite("Compliance")
    docs = {}
    for Test in ComplianceTest.__subclasses__():
        t = Test(suite, args.commits)
        t.run()
        suite.add_testcase(t.case)
        docs[t.case.name] = t._doc

    xml = JUnitXml()
    xml.add_testsuite(suite)
    xml.update_statistics()
    xml.write('compliance.xml')

    if args.github:
        repo = gh.get_repo(args.repo)
        pr = repo.get_pull(int(args.pull_request))
        commit = repo.get_commit(args.sha)

        comment = "Found the following issues, please fix and resubmit:\n\n"
        comment_count = 0
        print("Processing results...")
        for case in suite:
            if case.result and case.result.type != 'skipped':
                comment_count += 1
                comment += ("## {}\n".format(case.result.message))