pytest plugin for looping tests
Project description
pytest-loop is a plugin for pytest that makes it easy to loop a single test, or multiple tests, a specific number of times or for a certain duration of time. This plugin merges pytest-repeat and pytest-stress with a fix for test results.
Requirements
You will need the following prerequisites in order to use pytest-loop: - Python 3.6+ or PyPy - pytest 6 or newer
Only tested with Pytest version 6.2.5 and 7.0.1.
Installation
To install pytest-loop:
$ pip install pytest-loop
looping a test
Use the --loop
command line option to specify how many times you want
your test, or tests, to be run:
$ pytest --loop=10 test_file.py
Each test collected by pytest will be run n
times.
If you want to mark a test in your code to be looped a number of times, you
can use the @pytest.mark.loop(n)
decorator:
import pytest
@pytest.mark.loop(3)
def test_loop_decorator():
pass
looping 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-loop to force the test runner to stop at the first failure.
For example:
$ pytest --loop=1000 -x test_file.py
This will attempt to run test_file.py 1000 times, but will stop as soon as a failure occurs.
Resources
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file pytest-loop-1.0.5.tar.gz
.
File metadata
- Download URL: pytest-loop-1.0.5.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.10 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3f8f519ddc73f50d3b642919fa362eb813f511545b621d8238d3a82ea6ab93e |
|
MD5 | f5c665b44c63897ea6e967a420cba8c4 |
|
BLAKE2b-256 | d33a4637683686f1dd49f847743711137d3ba09d5323b5640fd2675da466ee11 |
File details
Details for the file pytest_loop-1.0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_loop-1.0.5-py2.py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.10 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1622fac7cbd7f78a91d5b3ca74cfe748bbdf0ae7538fa898c9e120ef95c45525 |
|
MD5 | 7c2e8764cfccbe63ad4da21789183353 |
|
BLAKE2b-256 | bc26d939c2ed2bd40934349391d806bf401d07f7e7cf818a1035a9bd56019d2c |