Beispiel #1
0
    def output_test_result_summary(
        self, test_results: List[TestResult], time_taken: float
    ):
        outcome_counts = self._get_outcome_counts(test_results)
        chart = self.generate_chart(
            num_passed=outcome_counts[TestOutcome.PASS],
            num_failed=outcome_counts[TestOutcome.FAIL],
            num_skipped=outcome_counts[TestOutcome.SKIP],
            num_xfail=outcome_counts[TestOutcome.XFAIL],
            num_unexp=outcome_counts[TestOutcome.XPASS],
        )
        print(chart, "")

        exit_code = get_exit_code(test_results)
        if exit_code == ExitCode.FAILED:
            result = colored(exit_code.name, color="red")
        else:
            result = colored(exit_code.name, color="green")
        print(
            f"{result} in {time_taken:.2f} seconds [ "
            f"{colored(str(outcome_counts[TestOutcome.FAIL]) + ' failed', color='red')}  "
            f"{colored(str(outcome_counts[TestOutcome.XPASS]) + ' xpassed', color='yellow')}  "
            f"{colored(str(outcome_counts[TestOutcome.XFAIL]) + ' xfailed', color='magenta')}  "
            f"{colored(str(outcome_counts[TestOutcome.SKIP]) + ' skipped', color='blue')}  "
            f"{colored(str(outcome_counts[TestOutcome.PASS]) + ' passed', color='green')} ]"
        )
Beispiel #2
0
def _(example=example_test):
    test_results = [
        TestResult(test=example, outcome=TestOutcome.XPASS),
        TestResult(test=example, outcome=TestOutcome.PASS),
    ]
    exit_code = get_exit_code(test_results)

    expect(exit_code).equals(ExitCode.FAILED)
Beispiel #3
0
def _(example):
    test_results = [
        TestResult(test=example, outcome=TestOutcome.PASS),
        TestResult(test=example, outcome=TestOutcome.SKIP),
        TestResult(test=example, outcome=TestOutcome.XFAIL),
    ]
    exit_code = get_exit_code(test_results)

    expect(exit_code).equals(ExitCode.SUCCESS)
Beispiel #4
0
def run(path, search, fail_limit):
    start_run = default_timer()

    mod_infos = get_info_for_modules(path)
    modules = list(load_modules(mod_infos))
    unfiltered_tests = get_tests_in_modules(modules)
    tests = search_generally(unfiltered_tests, query=search)
    time_to_collect = default_timer() - start_run

    suite = Suite(tests=list(tests))
    test_results = suite.generate_test_runs()

    writer = SimpleTestResultWrite(suite=suite)
    results = writer.output_all_test_results(test_results,
                                             time_to_collect=time_to_collect,
                                             fail_limit=fail_limit)
    time_taken = default_timer() - start_run
    writer.output_test_result_summary(results, time_taken)

    exit_code = get_exit_code(results)

    sys.exit(exit_code.value)
Beispiel #5
0
def _():
    exit_code = get_exit_code([])

    expect(exit_code).equals(ExitCode.NO_TESTS_FOUND)
Beispiel #6
0
def _():
    exit_code = get_exit_code([])

    expect(exit_code).equals(ExitCode.SUCCESS)