Skip to main content

SKY-L046 · Logic and resilience

Test result never checked

Low

A test that ends by storing the result of a call in a variable it never reads, with no assertion anywhere. The test computes the answer and then stops before comparing it with anything.

Languages
Python
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

The test only proves that the call did not raise. Whatever it returned, right or wrong, the test passes. This often happens when assertions are commented out or an agent leaves a test half written.

What Skylos flags

test_reachability.py · PythonReported on line 9
from deadcode.scan import find_unused  def test_common_name_cross_package_gets_lower_confidence():    files = {        "pkg/service.py": "class MyService:\n    def get(self):\n        return None\n",        "pkg/main.py": "data = {}\nresult = data.get('key')\n",    }    unused = find_unused(files)

What Skylos leaves alone

test_reachability.py · Python
import pickle from deadcode.scan import find_unused, scan_file  def test_scan_result_can_be_sent_to_workers():    result = scan_file("app.py")    pickle.dumps(result)  def test_scan_does_not_raise_on_empty_input():    find_unused({})

Why Skylos leaves it alone

The first test passes its result on (to pickle.dumps). The second does not keep the result at all, which reads as a deliberate "does not raise" check. Neither is reported.

How Skylos decides

  1. Runs with --quality on the same collected tests as SKY-L044. Looks at the test's last statement, stepping into a trailing with block.
  2. Reports when that statement assigns a call's result (awaited or not) to one or more plain names, none starting with _, that the test never reads.
  3. Leaves the test alone when it, or a function it calls that is defined in the same file, asserts, raises, or calls a function whose name contains assert, check, expect, verify, raises, fail, match, snapshot, should, ensure, validate or warns.
  4. Also left alone: xfail tests, tests that take a benchmark or snapshot fixture, and tests that return, yield or use global.

How to fix it

Assert on the stored result, or remove the assignment if the test only checks that the call does not raise.

test_reachability.py · Python · the fix, against the flagged file
from deadcode.scan import find_unused  def test_common_name_cross_package_gets_lower_confidence():    files = {        "pkg/service.py": "class MyService:\n    def get(self):\n        return None\n",        "pkg/main.py": "data = {}\nresult = data.get('key')\n",    }    unused = find_unused(files)Added:     assert unused["MyService.get"].confidence < 60

When it can be wrong

  • A test checked by a pytest plugin through a fixture name Skylos does not know is reported. Assert in the test, or suppress the line.
  • It misses a result that is read once but never compared, such as print(result).

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 assignment line.

    Python
    unused = find_unused(files)  # skylos: ignore[SKY-L046] checked by the session fixture
  • [tool.skylos] ignore = ["SKY-L046"] turns the rule off for the project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.