Skip to content

Update documentation to contain start time of test instead of end time #765

Open
@sturmf

Description

@sturmf

I added a time column as explained in the user documentation but this adds the end timestamp.
The following seems to achieve more what I want. Some feedback would be great and maybe it is worth updating the documentation?

import pytest
from datetime import datetime


def pytest_html_results_table_header(cells):
    cells.insert(2, '<th class="sortable time" data-column-type="time">Time</th>')


def pytest_html_results_table_row(report, cells):
    start = datetime.fromtimestamp(report.start)
    cells.insert(2, f'<td class="col-time">{start}</td>')


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    report.start = call.start

I am still a bit unsure about the different phases of a test like setup, call and teardown. Maybe this needs extra handling?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions