This rule raises an issue when a test intentionally aborts with assert False, assert 0, or a pytest.fail()
call that has no failure message.
In Python with pytest, this covers:
assert False or assert 0 used as an intentional abortpytest.fail() called without a non-empty message (including empty string and empty reason)Tests sometimes need to fail on purpose: a feature is not ready, a dependency is blocked, or a branch of the test should never succeed.
assert False and assert 0 look like accidental logic bugs rather than deliberate aborts. Readers cannot tell whether the
author meant to stop the test or left a broken condition behind.
pytest.fail() without a message fails the test but leaves no explanation in the report, so maintainers cannot triage the failure
without digging through history or comments.
pytest.fail("…") states the intent and records why the test stopped.
Intentional failures without a clear signal or message are harder to triage. Teams may waste time treating deliberate aborts as real assertion bugs, or overlook why a test is blocked.
Replace assert False / assert 0 with pytest.fail("…"), and always pass a concise message (or
reason=) that explains why the test fails.
import pytest
def test_not_ready():
assert False # Noncompliant
def test_blocked():
pytest.fail() # Noncompliant
import pytest
def test_not_ready():
pytest.fail("feature not implemented yet")
def test_blocked():
pytest.fail("blocked on issue 42")