Python · testing
defect-xfail-requires-strict
python:defect-xfail-requires-strict Bug-pinning `xfail` without `strict=True` — an XPASS reports as a pass and the pin rots.
- Code
- SARJ046
- Default
- error
- Fix
- none
- Languages
- python
Why
A non-strict defect pin stays green after the defect is fixed, leaving stale coverage and markers behind.
Fix
Set `strict=True` so an unexpected pass fails and prompts removal of the obsolete marker.
Before / after
Executed by this rule’s unit tests.
Before
Fixed defect would pass silently
import pytest
@pytest.mark.xfail(reason="BUG: wrong status code")
def test_status():
assert response_status() == 200
After
Fixed defect fails loudly
import pytest
@pytest.mark.xfail(reason="BUG: wrong status code", strict=True)
def test_status():
assert response_status() == 200
Limits
- Only xfail reasons that explicitly identify a defect are analyzed.
- Nondeterministic, property-based, integration, network, and environment-gated tests are excluded.
Formerly: xfail-requires-strict