Skip to content

Feature idea: rerun test if condition is not met (similar to hypothesis.assume()) #3475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rouge8 opened this issue May 15, 2018 · 3 comments

Comments

@rouge8
Copy link
Contributor

rouge8 commented May 15, 2018

Sometimes when running tests with semi-random data (e.g. from factory_boy), you know the test will fail if the generated data matches some condition. Rather than execute the test when you know it will fail, it would be nice if you could tell pytest to re-run that test, probably configurable up to N times. For example:

def test_something_with_different_people():
    person1, person2 = PersonFactory.build_batch(2)
    # if this is False, rerun the test up to N times
    pytest.assume(person1.name != person2.name)
    # some test that depends on the condition being true

This is inspired by assume() from hypothesis.

@RonnyPfannschmidt
Copy link
Member

there is pytest-rerunfaiures, please bring it up there

@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #2139 (Pytest own tests and hypothesis requirement), #2635 (test logging interaction no longer works due to hypothesis usage), #1946 (Test Generator similar to pythoscope?), #916 (Deep integration between Hypothesis and py.test is currently impossible), and #2946 (Failing pytester tests with features branch).

@rouge8
Copy link
Contributor Author

rouge8 commented May 15, 2018

Sure, moving to pytest-dev/pytest-rerunfailures#58

@rouge8 rouge8 closed this as completed May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants