Example #1
0
def print_processing_summary(results):
    tabular_data = []
    succeeded_nums = 0
    failed_nums = 0
    duration = 0

    for result in results:
        duration += result.get("duration", 0)
        if result.get("succeeded") is False:
            failed_nums += 1
            status_str = click.style("FAILED", fg="red")
        elif result.get("succeeded") is None:
            status_str = "IGNORED"
        else:
            succeeded_nums += 1
            status_str = click.style("SUCCESS", fg="green")

        tabular_data.append(
            (click.style(result['env'], fg="cyan"), status_str,
             util.humanize_duration_time(result.get("duration"))))

    click.echo()
    click.echo(tabulate(tabular_data,
                        headers=[
                            click.style(s, bold=True)
                            for s in ("Environment", "Status", "Duration")
                        ]),
               err=failed_nums)

    util.print_labeled_bar(
        "%s%d succeeded in %s" %
        ("%d failed, " % failed_nums if failed_nums else "", succeeded_nums,
         util.humanize_duration_time(duration)),
        is_error=failed_nums,
        fg="red" if failed_nums else "green")
Example #2
0
def print_testing_summary(results, verbose=False):
    click.echo()

    tabular_data = []
    succeeded_nums = 0
    failed_nums = 0
    duration = 0

    for result in results:
        duration += result.get("duration", 0)
        if result.get("succeeded") is False:
            failed_nums += 1
            status_str = click.style("FAILED", fg="red")
        elif result.get("succeeded") is None:
            if not verbose:
                continue
            status_str = "IGNORED"
        else:
            succeeded_nums += 1
            status_str = click.style("PASSED", fg="green")

        tabular_data.append(
            (
                result["test"],
                click.style(result["env"], fg="cyan"),
                status_str,
                util.humanize_duration_time(result.get("duration")),
            )
        )

    click.echo(
        tabulate(
            tabular_data,
            headers=[
                click.style(s, bold=True)
                for s in ("Test", "Environment", "Status", "Duration")
            ],
        ),
        err=failed_nums,
    )

    util.print_labeled_bar(
        "%s%d succeeded in %s"
        % (
            "%d failed, " % failed_nums if failed_nums else "",
            succeeded_nums,
            util.humanize_duration_time(duration),
        ),
        is_error=failed_nums,
        fg="red" if failed_nums else "green",
    )