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:

Why is this an issue?

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.

What is the potential impact?

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.

How to fix it

Replace assert False / assert 0 with pytest.fail("…​"), and always pass a concise message (or reason=) that explains why the test fails.

Code examples

Noncompliant code example

import pytest

def test_not_ready():
    assert False  # Noncompliant

def test_blocked():
    pytest.fail()  # Noncompliant

Compliant solution

import pytest

def test_not_ready():
    pytest.fail("feature not implemented yet")

def test_blocked():
    pytest.fail("blocked on issue 42")

Resources

Documentation

Related rules