A timer plugin for pytest
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
Consider insteadpytest-durationsPythie’s Index: 722.7M downloads/moCompare →
pip install pytest-timerpytest-timer
Porting of nose-timer plugin for pytest. A timer plugin for pytest (how much time does every test take?).
Install
To install the latest release from PyPI:
pip install pytest-timer
To install pytest-timer with termcolor for colored durations:
pip install pytest-timer[termcolor]
To install pytest-timer with colorama for colored durations:
pip install pytest-timer[colorama]
Or to install the latest development version from Git:
pip install git+git://github.com/skudriashev/pytest-timer.git
Or to install the latest from source:
git clone https://github.com/skudriashev/pytest-timer.git
cd pytest-timer
pip install .
You can also make a developer install if you plan on modifying the source frequently:
pip install -e .
Usage
After installing pytest-timer plugin the following report will be added:
========================== pytest-timer ==========================
[success] tests/test_plugin.py::TestPlugin::test_loaded2: 0.0002s
[success] tests/test_plugin.py::TestPlugin::test_loaded: 0.0002s
How do I show only the n slowest tests?
For example, to show only the 10 slowest tests, run pytest with the --timer-top-n flag:
pytest --timer-top-n 10
How do I turn off pretty colors?
In some cases, you may want to disable colors completely. This is done by using the --timer-no-color flag.
This is useful when running tests in a headless console.