pytest-dev / pytest-dev/pytest-rerunfailures
Feature request: rerun test if condition is not met (similar to hypothesis.assume())
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 477
- Forks
- 107
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 21
Description
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 True, rerun the test up to N times
rerun_if(person1.name == person2.name)
# some test that depends on `person1.name != person2.name`
This is inspired by assume() from hypothesis.
Originally opened as https://github.com/pytest-dev/pytest/issues/3475
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the requested rerun_if behavior, its similarity to Hypothesis assume(), and pytest's existing rerun configuration. No files, tests, or entry points are named; done would require an agreed design for detecting the condition, limiting retries to N, and verifying the behavior with tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100