This rule raises an issue when @pytest.mark.xfail is used without a reason parameter.
When writing tests, @pytest.mark.xfail marks a test as expected to fail, for example while a known bug remains unfixed.
@pytest.mark.xfail without reason leaves future maintainers without context for why the failure is expected. The
reason must appear on the decorator; comments or docstrings do not satisfy this rule.
Undocumented expected failures accumulate as the codebase changes, so teams cannot tell which markers still reflect real defects.
Add the reason parameter with a concise explanation or issue reference.
@pytest.mark.xfail # Noncompliant
def test_division_by_zero():
result = divide(10, 0)
assert result is None
@pytest.mark.xfail(reason='Issue #456: divide() should raise ValueError for zero divisor')
def test_division_by_zero():
result = divide(10, 0)
assert result is None