def test_save_loaded_report(tmpdir, sample_report):
    filename = tmpdir.join("report").strpath
    save_json(sample_report, filename)

    loaded_report = load_report(filename)
    loaded_report.end_time += 1
    loaded_report.save()

    reloaded_report = load_report(filename)
    assert reloaded_report.end_time == loaded_report.end_time
Esempio n. 2
0
    def run_cmd(self, cli_args):
        colorama.init()

        reporting_backends = auto_detect_reporting_backends()

        old_report = load_report(cli_args.old_report_path, reporting_backends)
        new_report = load_report(cli_args.new_report_path, reporting_backends)
        filtr = make_report_filter(cli_args)

        old_suites = filter_suites(old_report.get_suites(), filtr)
        new_suites = filter_suites(new_report.get_suites(), filtr)

        if len(old_suites) == 0 and len(new_suites) == 0:
            raise UserError(
                "The filter does not match any test on both reports")

        diff = compute_diff(old_suites, new_suites)
        display_diff(diff)

        return 0
Esempio n. 3
0
    def run_cmd(self, cli_args):
        report_path = get_report_path(cli_args)

        report = load_report(report_path, auto_detect_reporting_backends())
        suites = filter_suites(
            report.get_suites(),
            make_report_filter(cli_args, only_executed_tests=True))

        print_table("Tests, ordered by duration", ("Test", "Duration", "In %"),
                    TopTests.get_top_tests(suites))

        return 0
Esempio n. 4
0
    def run_cmd(self, cli_args):
        report_path = get_report_path(cli_args)

        report = load_report(report_path, auto_detect_reporting_backends())
        suites = filter_suites(
            report.get_suites(),
            make_report_filter(cli_args, only_executed_tests=True))

        print_table("Steps, aggregated and ordered by duration",
                    ("Step", "Occ.", "Min.", "Max", "Avg.", "Total", "In %"),
                    TopSteps.get_top_steps(suites))

        return 0
Esempio n. 5
0
    def run_cmd(self, cli_args):
        report_path = get_report_path(cli_args)
        report = load_report(report_path, auto_detect_reporting_backends())
        filtr = make_report_filter(cli_args)

        if cli_args.short:
            print_report_as_test_run(report, filtr)
        else:
            print_report(
                report, filtr=filtr, max_width=cli_args.max_width,
                explicit=cli_args.explicit or not sys.stdout.isatty()
            )

        return 0
Esempio n. 6
0
def _make_from_report_filter(cli_args, only_executed_tests=False):
    report = load_report(cli_args.from_report or DEFAULT_REPORT_DIR_NAME)
    filtr = _make_report_filter(cli_args, only_executed_tests=only_executed_tests)
    suites = filter_suites(report.get_suites(), filtr)
    return FromTestsFilter(flatten_tests(suites))
def _test_load_report(tmpdir, sample_report, save_func):
    filename = tmpdir.join("report").strpath
    save_func(sample_report, filename)
    report = load_report(filename)
    assert_report(report, sample_report)