How to use the junitparser.Failure 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 tytso / xfstests-bld / kvm-xfstests / test-appliance / files / usr / lib / python2.7 / gen_results_summary.py View on Github external
tests = testsuite.tests
    skipped = testsuite.skipped
    failures = testsuite.failures
    errors = testsuite.errors
    out_f.write('%s: %d tests, ' % (cfg, tests))
    if failures > 0:
        out_f.write('%d failures, ' % failures)
    if errors > 0:
        out_f.write('%d errors, ' % errors)
    if skipped > 0:
        out_f.write('%d skipped, ' % skipped)
    out_f.write('%d seconds\n' % runtime)
    if verbose:
        for test_case in testsuite:
            status = 'Pass'
            if isinstance(test_case.result, Failure):
                status = 'Failed'
            if isinstance(test_case.result, Skipped):
                status = 'Skipped'
            if isinstance(test_case.result, Error):
                status = 'Error'
            out_f.write("  %-12s %-8s %ds\n" %
                        (test_case.name, status, test_case.time))
    else:
        if failures > 0:
            print_tests(out_f, testsuite, Failure, 'Failures')
            if errors > 0:
                print_tests(out_f, testsuite, Error, 'Errors')
github IBM / watson-assistant-workbench / scripts / functions_test_evaluate.py View on Github external
except AttributeError:
            pass

        if not testOutputReturnedPath:
            logger.debug("Returned output payload provided inside the test")

        # evaluate test
        if 'type' not in test or test['type'] == 'EXACT_MATCH':
            testResultString = DeepDiff(testOutputExpectedJson, testOutputReturnedJson, ignore_order=True).json
            testResultJson = json.loads(testResultString)
            if testResultJson == {}:
                test['result'] = 0
            else:
                test['result'] = 1
                test['diff'] = testResultJson
                case.result = Failure(json.dumps(testResultJson, sort_keys=True))
        else:
            errorMessage = "Unknown test type: {}".format(test['type'])
            logger.error(errorMessage)
            case.result = Error(errorMessage, 'ValueError')

        testCounter += 1

    # write outputs
    if junitFileName:
        xml.write(junitFileName, True)
    outputFile.write(json.dumps(inputJson, indent=4, ensure_ascii=False) + '\n')

    logger.info('FINISHING: '+ os.path.basename(__file__))
github tytso / xfstests-bld / kvm-xfstests / test-appliance / files / usr / lib / python2.7 / gen_results_summary.py View on Github external
out_f.write('%d skipped, ' % skipped)
    out_f.write('%d seconds\n' % runtime)
    if verbose:
        for test_case in testsuite:
            status = 'Pass'
            if isinstance(test_case.result, Failure):
                status = 'Failed'
            if isinstance(test_case.result, Skipped):
                status = 'Skipped'
            if isinstance(test_case.result, Error):
                status = 'Error'
            out_f.write("  %-12s %-8s %ds\n" %
                        (test_case.name, status, test_case.time))
    else:
        if failures > 0:
            print_tests(out_f, testsuite, Failure, 'Failures')
            if errors > 0:
                print_tests(out_f, testsuite, Error, 'Errors')
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
def run(self):
        self.prepare()

        proc = subprocess.Popen('gitlint --commits %s' % (self.commit_range),
                                shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

        msg = ""
        if proc.wait() != 0:
            msg = proc.stdout.read()

        if msg != "":
            text = (msg.decode('utf8'))
            self.case.result = Failure("commit message syntax issues", "failure")
            self.case.result._elem.text = text
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
error1 = "%s: author email (%s) needs to match one of the signed-off-by entries." % (sha, author)
            error2 = "%s: author email (%s) does not follow the syntax: First Last ." % (sha, author)
            failure = None
            if author not in signed:
                failure = error1

            if not parsed_addr or len(parsed_addr[0].split(" ")) < 2:
                if not failure:

                    failure = error2
                else:
                    failure = failure + "\n" + error2


            if failure:
                self.case.result = Failure("identity/email issues", "failure")
                self.case.result._elem.text = failure
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
def run(self):
        self.prepare()
        diff = subprocess.Popen(('git', 'diff', '%s' %(self.commit_range)), stdout=subprocess.PIPE)
        try:
            output = subprocess.check_output(('%s/scripts/checkpatch.pl' %zephyr_path,
                '--mailback', '--no-tree', '-'), stdin=diff.stdout,
                stderr=subprocess.STDOUT, shell=True)

        except subprocess.CalledProcessError as ex:
            m = re.search("([1-9][0-9]*) errors,", ex.output.decode('utf8'))
            if m:
                self.case.result = Failure("Checkpatch issues", "failure")
                self.case.result._elem.text = (ex.output.decode('utf8'))
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
os.environ["ARCH"] = "*"

        # Enable strict Kconfig mode in Kconfiglib, which assumes there's just a
        # single Kconfig tree and warns for all references to undefined symbols
        os.environ["KCONFIG_STRICT"] = "y"

        undef_ref_warnings = []

        for warning in kconfiglib.Kconfig().warnings:
            if "undefined symbol" in warning:
                undef_ref_warnings.append(warning)

        # Generating multiple JUnit s would be neater, but Shippable only
        # seems to display the first one
        if undef_ref_warnings:
            self.case.result = Failure("undefined Kconfig symbols", "failure")
            self.case.result._elem.text = "\n\n\n".join(undef_ref_warnings)
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
licenses = file['licenses']
                if (file['is_script'] or file['is_source']) and (file['programming_language'] not in ['CMake']) and (file['extension'] not in ['.yaml']):
                    if len(file['licenses']) == 0:
                        report += ("* {} missing license.\n".format(original_fp))
                    else:
                        for l in licenses:
                            if l['key'] != "apache-2.0":
                                report += ("* {} is not apache-2.0 licensed: {}\n".format(original_fp, l['key']))
                            if l['category'] != 'Permissive':
                                report += ("* {} has non-permissive license: {}\n".format(original_fp, l['key']))

                    if len(file['copyrights'])  == 0:
                        report += ("* {} missing copyright.\n".format(original_fp))

        if report != "":
            self.case.result = Failure("License/Copyright issues", "failure")
            self.case.result._elem.text = report