Py.test run until pass decorator

pytest, python

Solution

You could use `retry` decorator:

@retry(AssertionError, tries=10)
def test_get_info(self):
    assert info == 1

Note: it doesn't take into account `setup`, `teardown` methods.

Problem

I have some tests which uploaded different data (music, video) and get metadata from service. So time.sleep() is a really bad way, because different servers and situations could overload system. So I'm looking special decorator or parameter to set. Something like this ``` @fails(10) def test_get_info(self): assert info == 1 ``` After 10 attempts assert is still failed - raise Exception. Thank you.

Original source