pytest rerun class failures plugin
Project description
Pytest rerun class failures plugin
This plugin helps to rerun whole test classes that failed during the test run. This means in case of failure of any class within the test class, the whole class will be rerun. Due to that, in case of failure plugin will fail fast: the rest of the tests in class will be aborted and will not be run. Instead of that, all tests from the class will be rerun starting first one. The plugin supports proper class teardown and reset attribute of the class to initial values. So it will be reset before each rerun.
Installation
You can install the plugin via pip:
pip install pytest-rerunclassfailures
Usage
After installation plugin ready to use, you do not need to pass extra options or add plugin to pytest.ini. Just run your tests as usual:
pytest tests --rerun-class-max=2
You always need pass --rerun-class-max with number of reruns for the class. By default, the plugin is disabled.
Other options you may use:
--rerun-class-max- number of reruns for the class. Default is 0.--rerun-delay- delay between reruns in seconds. Default is 0.5.--rerun-show-only-last- show only last rerun results (without 'reruns' in log), by default is not used.--hide-rerun-details- hide rerun details in the log ('RERUNS' section in terminal), by default is not used.
PYTHONPATH=. pytest -s tests -p pytest_rerunclassfailures --rerun-class-max=3 --rerun-delay=1 --rerun-show-only-last
In some cases you may manage plugins manually, so, you can do it in two ways:
- Run your tests with plugin by passing by
-poption:
PYTHONPATH=. pytest -s tests -p pytest-rerunclassfailures --rerun-class-max=3
- Add plugin to
pytest.inifile:
[pytest]
plugins = pytest-rerunclassfailures
addopts = --rerun-class-max=3
To disable plugin (even ignoring passed --rerun-class-max option) use:
pytest test -p no:pytest-rerunclassfailures
pytest-xdist support
Plugin supports pytest-xdist plugin.
It means that you can run tests in parallel and rerun failed classes in parallel as well.
But please note that every class tests method should schedule to run in the same worker.
So the plugin can rerun the whole class in the same worker.
To do so, you need to run your tests with --dist=loadscope option.
Otherwise, there's no guarantee that results will be predictable.
Known limitations
- Please note, this plugin still not supports rerun of the class setup method. This means that if you use class-scoped fixtures, they will not be rerun, only class attributes will be reset to initial values.
- Due to
pytest-xdistplugin limitations, report output will be thrown only when all tests in class are executed. This means that you will not see the output of the failed test until all tests in the class are rerun. Unfortunately,pytest-xdistplugin allows reporting results for only scheduled tests in scheduled order. Due to that, tests in class will be grouped by test, but not by rerun, as in regular run. - Never use this plugin with
pytest-rerunfailuresplugin. It will not work as expected.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_rerunclassfailures-0.1.1.tar.gz.
File metadata
- Download URL: pytest_rerunclassfailures-0.1.1.tar.gz
- Upload date:
- Size: 222.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ad6152a3de557d8fc67914e9b582bf6e76b4f37180c101ee74d1767a97962ff
|
|
| MD5 |
4008f728ae0a601ffc95c7539f002216
|
|
| BLAKE2b-256 |
bc9083e83ad73f0f16883c098a434ea6b44c4a96864a53739178e252be64d54d
|
File details
Details for the file pytest_rerunclassfailures-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pytest_rerunclassfailures-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f10ff067db3db9dfc636ab0ac50c66072971d7da521d20cc7d813274c27b80be
|
|
| MD5 |
1a4a0be76d08f2761a0ddedbdcba9773
|
|
| BLAKE2b-256 |
a703f776c18860e479706036a10819e3cd7ae95692b329dd617debe2ba34ac13
|