Пример #1
0
 def format_steps_aggregation(description, occurrences, min_duration,
                              max_duration, average_duration, duration,
                              duration_pct):
     return (description, str(occurrences),
             humanize_duration(min_duration, show_milliseconds=True),
             humanize_duration(max_duration, show_milliseconds=True),
             humanize_duration(average_duration, show_milliseconds=True),
             humanize_duration(duration, show_milliseconds=True),
             "%d%%" % duration_pct)
Пример #2
0
def get_message_template_parameters():
    return {
        "start_time":
        lambda report, stats: time.asctime(time.localtime(report.start_time)),
        "end_time":
        lambda report, stats: time.asctime(time.localtime(report.end_time)),
        "duration":
        lambda report, stats: humanize_duration(report.end_time - report.
                                                start_time),
        "total":
        lambda report, stats: stats.tests,
        "enabled":
        lambda report, stats: stats.enabled_tests,
        "passed":
        lambda report, stats: stats.test_statuses["passed"],
        "passed_pct":
        lambda report, stats: percent(stats.test_statuses["passed"],
                                      of=stats.enabled_tests),
        "failed":
        lambda report, stats: stats.test_statuses["failed"],
        "failed_pct":
        lambda report, stats: percent(stats.test_statuses["failed"],
                                      of=stats.enabled_tests),
        "skipped":
        lambda report, stats: stats.test_statuses["skipped"],
        "skipped_pct":
        lambda report, stats: percent(stats.test_statuses["skipped"],
                                      of=stats.enabled_tests),
        "disabled":
        lambda report, stats: stats.test_statuses["disabled"],
        "disabled_pct":
        lambda report, stats: percent(stats.test_statuses["disabled"],
                                      of=stats.tests)
    }
Пример #3
0
 def format_suite_entry(suite, total_time):
     if suite.duration is not None:
         return (suite.path, len(suite.get_tests()),
                 humanize_duration(suite.duration, show_milliseconds=True),
                 "%d%%" % (suite.duration / total_time * 100))
     else:
         return suite.path, len(suite.get_tests()), "-", "-"
Пример #4
0
 def format_test_entry(test, total_time):
     if test.duration is not None:
         return (test.path,
                 humanize_duration(test.duration, show_milliseconds=True),
                 "%d%%" % (test.duration / total_time * 100))
     else:
         return test.path, "-", "-"
Пример #5
0
    def render_steps(self, steps):
        rows = []
        for step in steps:
            rows.append([
                "",
                colored(
                    self.wrap_description_col(step.description),
                    color=outcome_to_color(step.is_successful()),
                    attrs=["bold"]
                ),
                colored(humanize_duration(step.duration, show_milliseconds=True), attrs=["bold"])
                    if step.duration is not None else "-"
            ])
            for entry in step.entries:
                if isinstance(entry, Log):
                    rows.append([
                        colored(entry.level.upper(), color=log_level_to_color(entry.level), attrs=["bold"]),
                        self.wrap_description_col(entry.message)
                    ])
                if isinstance(entry, Check):
                    rows.append([
                        self.render_check_outcome(entry.outcome),
                        self.wrap_description_col(entry.description),
                        self.wrap_details_col(entry.details)
                    ])
                if isinstance(entry, Url):
                    rows.append([
                        colored("URL", color="cyan", attrs=["bold"]),
                        self.wrap_description_col("%s (%s)" % (entry.url, entry.description))
                    ])
                if isinstance(entry, Attachment):
                    rows.append([
                        colored("ATTACH", color="cyan", attrs=["bold"]),
                        self.wrap_description_col(entry.description),
                        entry.filename
                    ])

        table = AsciiTable(rows)
        table.inner_heading_row_border = False
        table.justify_columns[0] = "center"
        table.inner_row_border = True

        return table.table