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.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

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 py.test’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.5.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

pytest_repeat-0.5.0-py2.py3-none-any.whl (3.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for pytest-repeat-0.5.0.tar.gz
Algorithm Hash digest
SHA256 769a59b75a80914f1a2ef94a8fa61500eb303c4e3414b9ba0738524ec586bb60
MD5 770dd795374dbe33affba87e04c41946
BLAKE2b-256 f854e2a8d2231a568c6a45789cc3aa646c1647df5505cb66ed0f6f24fbdfa178

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_repeat-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0fb0fb8cd604530bdaa8ed629e0582e92e171facb509470323190ebbd47496eb
MD5 4a3c503b477648fa0c97a73fe67379dd
BLAKE2b-256 4b9c2057241715fd611228cc7b7d68691a1b797caddb0bbf3a71c24814ed40b8

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