SKY-L040 · Logic and resilience
Constant assertion in test
An assert in a test whose condition is made only of literals and is always true, such as assert True or assert 1 == 1. It can never fail, so it checks nothing.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
The test passes whatever the code under test does. Coding agents write such asserts to make a test go green; the suite then reports coverage of behaviour that is not checked at all.
What Skylos flags
from shop.pricing import cart_total def test_cart_total_applies_discount(): total = cart_total([{"price": 100, "qty": 2}], discount=0.1) assert TrueWhat Skylos leaves alone
from shop.pricing import cart_total def test_cart_total_applies_discount(): total = cart_total([{"price": 100, "qty": 2}], discount=0.1) assert total is not NoneWhy Skylos leaves it alone
This check is weak, but it is not constant: it reads total, a value the code under test produced, and fails if cart_total returns None. Skylos only reports conditions it can prove true from literals alone.
How Skylos decides
- Runs with
--qualityon Python test files that pytest would collect under the project's settings (python_files,testpaths,norecursedirs;test_*.pyand*_test.pyby default) and onunittest.TestCaseclasses whose base is proven by the imports. - Looks only at directly declared test functions and methods. Skipped or
xfailtests,conftest.py, fixture and snapshot folders, and nested functions are left out. - Reports an
assertwhose condition contains only literals, tuples, lists,not,and/or,+/-and comparisons, and evaluates to true. Any name, call or attribute stops the check. Asserts Skylos knows can never run are skipped. - Reports LOW on the line of the
assert.
How to fix it
Assert the result the test is named after.
from shop.pricing import cart_total def test_cart_total_applies_discount(): total = cart_total([{"price": 100, "qty": 2}], discount=0.1)Removed: assert TrueAdded: assert total == 180When it can be wrong
- A smoke test that only checks that an import or a call does not raise, and ends with
assert Trueto say so, is reported. Removing theassertkeeps the same meaning.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the line of the
assert.Python assert True # skylos: ignore[SKY-L040] import smoke test[tool.skylos] ignore = ["SKY-L040"]turns the rule off for the project.