Skip to content

QA-PY-012 — Tautological assertion ​

← Back to the rule catalog

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

FieldValue
Severityerror
Confidencehigh
Tierquarantine
Measured FP rate40% (n=30)
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 ​

assert True and assert x == x are literal tautologies in Python exactly as expect(true).toBe(true) is in JS — they cannot raise AssertionError by construction, so pytest reports success regardless of what the code under test actually did. It is worth calling out as its own rule (rather than folding into QA-PY-003) because unlike a missing assertion, this pattern is easy to mistake for a real check on a quick read of the diff — the word assert is right there.

What gets flagged (real detector output) ​

Tautological assertion: `assert True`.

Example from this rule's own must-fire fixture: tests/fixtures/QA-PY-012/must-fire/tautological.py

The fix ​

Assert on actual output of the code under test.

Confirmed NOT to fire on the corresponding clean pattern ​

Verified against tests/fixtures/QA-PY-012/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-airflow6
getsentry-sentry1
negative-fixtures1
positive-fixtures15
pyca-cryptography5
pytest-dev-pytest5
reflex-dev-reflex1
streamlit-streamlit2

Released under the MIT License.