Get session duration from terminal reporter #10147
-
I'd like to retrieve the session duration for use in the pytest-html report. Is that possible today? From what I can tell, it's not available on the TerminalReporter object. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Do you need the exact same time as the one printed by pytest? If not, you can probably just implement |
Beta Was this translation helpful? Give feedback.
Do you need the exact same time as the one printed by pytest? If not, you can probably just implement
pytest_sessionstart
andpytest_sessionfinish
like the terminalreporter does (or perhaps a hookwrapper aroundpytest_cmdline_main
if you just want one function?), and then usetime.time()
there to get the time yourself. Should only be off by whatever time the terminalreporter needs itself.