Skip to content

Instantly share code, notes, and snippets.

@harupy
Last active January 26, 2021 23:43
Show Gist options
  • Save harupy/29b20a951b8a69dcc3fd5f3a253a6cc5 to your computer and use it in GitHub Desktop.
Save harupy/29b20a951b8a69dcc3fd5f3a253a6cc5 to your computer and use it in GitHub Desktop.
@pytest.hookimpl(hookwrapper=True)
def pytest_report_teststatus(report, config):
outcome = yield
res = outcome.get_result()
attr_name = "___TIME___"
if report.when == "setup":
# HACK: store the start time in `config`
setattr(config, attr_name, time.time())
elif report.when == "call":
start = getattr(config, attr_name)
new_res = res[:2] + (res[2] + " ({:.3f} s)".format(time.time() - start),)
outcome.force_result(new_res)
@harupy
Copy link
Author

harupy commented Nov 28, 2020

Screen Shot 2020-11-29 at 1 14 05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment