Skip to main content

pytest-repeat

pytest-repeat is a plugin for py.test that makes it easy to repeat a single test, or multiple tests, a specific number of times.

License PyPI Travis Issues Requirements

Requirements

You will need the following prerequisites in order to use pytest-repeat:

  • Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5 or PyPy

  • py.test 2.8 or newer

Installation

To install pytest-repeat:

$ pip install pytest-repeat

Repeating a test

Use the --count command line option to specify how many times you want your test, or tests, to be run:

$ py.test --count=10 test_file.py

Each test collected by py.test will be run count times.

If you want to mark a test in your code to be repeated a number of times, you can use the @pytest.mark.repeat(count) decorator:

import pytest


@pytest.mark.repeat(3)
def test_repeat_decorator():
    pass

If you want to override default tests executions order, you can use --repeat-scope command line option with one of the next values: session, module, class or function (default). It behaves like a scope of the pytest fixture.

function (default) scope repeats each test count or 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. class and 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. For example:

$ py.test --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.

Resources

Metadata

Release files for pytest-repeat 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-repeat 0.6.0
File Size Uploaded
pytest-repeat-0.6.0.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-repeat 0.6.0
File Interpreter ABI Platform
pytest_repeat-0.6.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.4 kB

Release files / pytest-repeat-0.6.0.tar.gz

Download URL pytest-repeat-0.6.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
84aba2fcca5dc2f32ae626a01708f469f17b3384ec3d1f507698077f274909d6
BLAKE2b-256 checksum
How to use checksums
62526fdeac5f3b8ad54d5262b3dadf87e1ef20d76498184f2e8aba612f387c62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.5

Release files / pytest_repeat-0.6.0-py2.py3-none-any.whl

Download URL pytest_repeat-0.6.0-py2.py3-none-any.whl
Size 3.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7555fb2107815b30fe7ee6e575a8143305a2d793dfad4c8764a7e6476ba5d0c2
BLAKE2b-256 checksum
How to use checksums
c1906f28b965d76a3cb2243b349180d61c43e750c400edd7a44e924b3130d3f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.5

Release history Release notifications | RSS feed

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page