import pytest @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() if report.when == "call": report._duration_str = f"{report.duration:.2f}s" def pytest_report_teststatus(report, config): if report.when == "call" and hasattr(report, "_duration_str"): t = report._duration_str if report.passed: return "passed", ".", (f"PASSED ({t})", {"green": True}) if report.failed: return "failed", "F", (f"FAILED ({t})", {"red": True}) if report.skipped: return "skipped", "s", (f"SKIPPED ({t})", {"yellow": True})