Complete the code to mark a test as flaky using pytest.
import pytest @pytest.[1](reruns=3) def test_example(): assert True
The correct decorator to mark a test for reruns in pytest is @pytest.mark.flaky. Here, mark is used as @pytest.mark.flaky with the reruns argument.
Complete the code to retry a flaky test 5 times with pytest.
import pytest @pytest.mark.flaky(reruns=[1]) def test_retry(): assert False
Setting reruns=5 tells pytest to retry the test up to 5 times if it fails.
Fix the error in the flaky test decorator syntax.
import pytest @pytest.mark.flaky(reruns=[1]) def test_fail(): assert False
The reruns parameter must be an integer, not a string or other type.
Fill both blanks to retry a flaky test 4 times and delay retries by 2 seconds.
import pytest @pytest.mark.flaky(reruns=[1], reruns_delay=[2]) def test_delayed_retry(): assert False
Use reruns=4 to retry 4 times and reruns_delay=2 to wait 2 seconds between retries.
Fill all three blanks to retry a flaky test 3 times, delay 1 second between retries, and only rerun on AssertionError.
import pytest @pytest.mark.flaky(reruns=[1], reruns_delay=[2], reruns_exceptions=[3]) def test_specific_exception(): assert False
Set reruns=3 for retry count, reruns_delay=1 for delay, and reruns_exceptions=(AssertionError,) to retry only on assertion failures.