pythonpytestpytest-htmlpytest-xdist

How can I get the accurate time spent in the pytest-html report when the tests are run in parallel (via pytest-xdist)?


I've noticed an error in the report generated by pytest-html and I'm surprised I can't find it mentioned anywhere.

I am running a series of tests (70 total) and using pytest-html to generate a report on the results. I am also using pytest-xdist so that the tests run in parallel.

When the test run is complete, I look at the terminal to how long it took for everything and see:

2 failed, 68 passed in 146.09s (0:02:26)

These are UI tests so two and a half minutes isn't that bad; also it's why these need to be run in parallel.

But when I look at the pytest-html report, it says:

70 tests took 00:23:32.

The report doesn't look at the actual start and finish time. It's using the times of each of the tests and summing them together.

How can I update the report to show the real time spent, not the total of the individual tests?


Solution

  • This was fixed:

    However, the latest version on PyPI (4.1.1) was published before the fix.

    You can get the latest code with this included from the GitHub repository: