Skip to content

QA-PY-003 — Test function with no assertions ​

← Back to the rule catalog

Generated from the rule registry. Get the same detail from the CLI with mjolnir explain QA-PY-003.

FieldValue
Severityerror
Confidencehigh
Tierquarantine
Measured FP rate52% (n=33)
Evidence levelE2
QA impactFalse-green risk (FALSE-GREEN)
False-positive risk (author estimate)low
Autofix availableno
Languagespython
Frameworkspytest
Detection strategyLEXICAL
Introduced inv0.3.0

Why this fails in production ​

A pytest test function with no assert statement (and no call into a helper that itself asserts) can execute every line of the code under test and still verify nothing — pytest reports it as passed because nothing raised AssertionError or any other exception. This is the same failure mode as QA-TEST-003, in pytest's idiom: no expect() API to omit, just a missing assert keyword, which makes it easy to write a test that only calls the function under test for its side effects and never checks the result.

What gets flagged (real detector output) ​

Test `test_login_no_assertion` contains no assertions.

Example from this rule's own must-fire fixture: tests/fixtures/QA-PY-003/must-fire/no-assert.py

The fix ​

Add an assert on the expected outcome, or remove the test.

Confirmed NOT to fire on the corresponding clean pattern ​

Verified against tests/fixtures/QA-PY-003/must-not-fire/clean.py — a legitimate, similar-looking pattern this rule correctly leaves alone.

Corpus-measured false-positive risk ​

Real occurrence counts from npm run corpus:audit against actively-maintained OSS repos — reproduce yourself, don't just trust this table (see the false-positive audit):

RepoOccurrences
apache-airflow45
getsentry-sentry1
pallets-click3
positive-fixtures13
psf-requests3
pyca-cryptography44
pytest-dev-pytest30
reflex-dev-reflex53
streamlit-streamlit29

Released under the MIT License.