pytest-durations is an active pytest plugin, currently at version 1.6.2, designed to report detailed execution times for both test functions and their associated fixtures. Unlike pytest's built-in `--durations` feature, it separates these timings and offers compatibility with distributed testing frameworks like pytest-xdist and time-traveling packages. The library sees frequent updates, with multiple minor and patch releases occurring throughout the year.
pip install pytest-durationsNo compatibility data collected yet for this library.
To use pytest-durations, simply install the plugin. It integrates automatically with pytest. Create a test file, then run pytest with the `--pytest-durations=N` option to show the N slowest durations. You can also specify `--pytest-durations-log=FILE` to output results to a file.
Upgrade to Python 3.10 or a newer compatible version.
Update parsing logic to expect the 'med' column instead of 'avg'.
Update scripts to use `--pytest-durations-log` instead of `--pytest-resultlog`.
Review the impact of `time.time()` vs `time.monotonic()` on your specific use cases, especially with time-traveling libraries. Consider testing against affected versions.
Use `--pytest-durations` for the plugin's enhanced reporting, and be aware of the distinct information it provides compared to the native `--durations`.
Specify `--pytest-durations-group-by=legacy` if you need the old grouping behavior, or update your parsing logic to handle new grouping options.
Install the plugin in your active virtual environment: `pip install pytest-durations`.
To get detailed test and fixture timings, use the plugin's specific options, for example: `pytest --durations-path durations_report.json`.
Ensure the target directory for the report file exists before running pytest; for example: `mkdir -p some/nonexistent/path && pytest --durations-path some/nonexistent/path/report.json`.
Run pytest with the `--durations-path` option, e.g., `pytest --durations-path=durations.json`
Upgrade your pytest installation to a compatible version: `pip install --upgrade pytest`