<commit_before>flaky
=====

.. image:: https://travis-ci.org/box/flaky.png?branch=master
    :target: https://travis-ci.org/box/flaky

.. image:: https://pypip.in/v/flaky/badge.png
    :target: https://pypi.python.org/pypi/flaky

.. image:: https://pypip.in/d/flaky/badge.png
    :target: https://pypi.python.org/pypi/flaky


About
-----

Flaky is a plugin for nose or py.test that automatically reruns flaky tests.

Ideally, tests reliably pass or fail, but sometimes test fixtures must rely on components that aren't 100%
reliable. With flaky, instead of removing those tests or marking them to @skip, they can be automatically
retried.

Marking tests flaky
~~~~~~~~~~~~~~~~~~~

To mark a test as flaky, simply import flaky and decorate the test with @flaky:

.. code-block:: python

    from flaky import flaky

.. code-block:: python

    @flaky
    def test_something_that_usually_passes(self):
        value_to_double = 21
        result = get_result_from_flaky_doubler(value_to_double)
        self.assertEqual(result, value_to_double * 2, 'Result doubled incorrectly.')

By default, flaky will retry a failing test once, but that behavior can be overridden by passing values to the
flaky decorator. It accepts two parameters: max_runs, and min_passes; flaky will run tests up to max_runs times, until<commit_msg>Update README.rst<commit_after>flaky
=====

.. image:: https://travis-ci.org/box/flaky.png?branch=master
    :target: https://travis-ci.org/box/flaky

.. image:: https://pypip.in/v/flaky/badge.png
    :target: https://pypi.python.org/pypi/flaky

.. image:: https://pypip.in/d/flaky/badge.png
    :target: https://pypi.python.org/pypi/flaky


About
-----

Flaky is a plugin for nose or py.test that automatically reruns flaky tests.

Ideally, tests reliably pass or fail, but sometimes test fixtures must rely on components that aren't 100%
reliable. With flaky, instead of removing those tests or marking them to @skip, they can be automatically
retried.

For more information about flaky, see `this presentation <http://opensource.box.com/flaky/>`_.

Marking tests flaky
~~~~~~~~~~~~~~~~~~~

To mark a test as flaky, simply import flaky and decorate the test with @flaky:

.. code-block:: python

    from flaky import flaky

.. code-block:: python

    @flaky
    def test_something_that_usually_passes(self):
        value_to_double = 21
        result = get_result_from_flaky_doubler(value_to_double)
        self.assertEqual(result, value_to_double * 2, 'Result doubled incorrectly.')

By default, flaky will retry a failing test once, but that behavior can be overridden by passing values to the
flaky decorator. It accepts two parameters: max_runs, and min_passes; flaky will run tests up to max_runs times, until
{'fraction_non_alphanumeric': 0.11094890510948906, 'fraction_numerical': 0.004379562043795621, 'mean_word_length': 3.8257042253521125, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3648474', 'n_tokens_mistral': 906, 'n_tokens_neox': 852, 'n_words': 287}