pytest plugin for repeating tests
pytest-repeat is a plugin for pytest that makes it easy to repeat a single test, or multiple tests, a specific number of times.
You will need the following prerequisites in order to use pytest-repeat:
- Python 2.7, 3.5+ or PyPy
- pytest 3.6 or newer
To install pytest-repeat:
$ pip install pytest-repeat
Repeating a test
--count command line option to specify how many times you want
your test, or tests, to be run:
$ pytest --count=10 test_file.py
Each test collected by pytest will be run
If you want to mark a test in your code to be repeated a number of times, you
can use the
import pytest @pytest.mark.repeat(3) def test_repeat_decorator(): pass
If you want to override default tests executions order, you can use
command line option with one of the next values:
It behaves like a scope of the pytest fixture.
function (default) scope repeats each test
repeat times before executing next test.
session scope repeats whole tests session, i.e. all collected tests executed once, then all such tests executed again and etc.
module behaves similar
session , but repeating set of tests is a tests from class or module, not all collected tests.
Repeating a test until failure
If you are trying to diagnose an intermittent failure, it can be useful to run the same
test over and over again until it fails. You can use pytest’s
-x option in
conjunction with pytest-repeat to force the test runner to stop at the first failure.
$ pytest --count=1000 -x test_file.py
This will attempt to run test_file.py 1000 times, but will stop as soon as a failure occurs.
UnitTest Style Tests
Unfortunately pytest-repeat is not able to work with unittest.TestCase test classes.
These tests will simply always run once, regardless of
--count, and show a warning.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pytest_repeat-0.9.1-py2.py3-none-any.whl (4.3 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size pytest-repeat-0.9.1.tar.gz (7.3 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for pytest_repeat-0.9.1-py2.py3-none-any.whl