Skip to content

python/test-rerun

Pack Severity Fix Versions
Python warning none, edit by hand All versions

Rerunning a test until it passes hides why it fails some of the time. Find the cause, or delete the test and write down why.

@pytest.mark.flaky(reruns=3)
def test_worker():
done = threading.Event()
start(done)
assert done.is_set()
assert done.wait(timeout=5)

The rule reports pytest.mark.flaky and an import of flaky in a test file.

xpd has no automatic fix, so make the change by hand.

A test that is run again until it passes hides the run where the code was wrong, and it teaches whoever reads the result to run the suite once more instead of fixing the code. Find why the test fails some of the time, which is often an order or a wait that the test doesn't control. When the cause can't be found, delete the test and write down why.

This runs the test again until it passes. Find why it fails some of the time, or delete the test and write down why.

See all rules in the Python pack.