B. The decorator should be @pytest.retry, not @pytest.mark.flaky
C. The parameter name should be 'reruns', not 'rerun'
D. The test cannot retry if it always fails
Solution
Step 1: Check the decorator parameter spelling
The correct parameter for retry count is reruns, not rerun.
Step 2: Understand impact of wrong parameter
Using rerun is ignored by pytest, so no retries happen despite failures.
Final Answer:
The parameter name should be 'reruns', not 'rerun' -> Option C
Quick Check:
Correct param spelling = reruns [OK]
Hint: Check exact parameter spelling: reruns, not rerun [OK]
Common Mistakes:
Misspelling reruns parameter
Using wrong decorator name
Expecting retries on always failing test
5. You want to reduce false failures from a flaky test that sometimes fails due to timing issues. Which approach best combines flaky test detection and retry in pytest?
hard
A. Use @pytest.mark.flaky(reruns=3) and add explicit wait in test code
B. Use @pytest.mark.skip to ignore the flaky test
C. Remove retries and fix test to always pass
D. Use @pytest.mark.flaky(reruns=0) to disable retries
Solution
Step 1: Understand flaky test retry purpose
Retries help reduce false failures by rerunning tests that fail randomly.