Skip to main content

pytest plugin for repeating tests

Project description

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.7, 3.4+ 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

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

pytest-repeat-0.8.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

pytest_repeat-0.8.0-py2.py3-none-any.whl (4.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-repeat-0.8.0.tar.gz.

File metadata

  • Download URL: pytest-repeat-0.8.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for pytest-repeat-0.8.0.tar.gz
Algorithm Hash digest
SHA256 52bc413ab1a772e72c953a5592196ddd266fd2e76280eaac0c2a8378e9ac6dd9
MD5 8301c6be12215654bdbd635b53e72d78
BLAKE2b-256 1aefa721646e592e834ad93e1c880956b3d6ff060c623c2e317170f5747d9c71

See more details on using hashes here.

File details

Details for the file pytest_repeat-0.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_repeat-0.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for pytest_repeat-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f506cf5b3306cc4308c4a76f6d8988a9f61c1c2609d48ad422e26a8e37ae50c4
MD5 5d160d58ec6ab06f8ea9870ec50a7d04
BLAKE2b-256 2edec1d69002db74a99b3df0463e95066c03d82d9d2a53be738c140207134e0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page