Skip to main content

SKY-L044 · Logic and resilience

Test runs no project code

Low

A test in which every name it reads is one the test bound itself, or a pure builtin such as len, sum or sorted. The test builds its own values and asserts on them, or re-implements the logic it claims to check, so nothing from the project is ever called.

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 passes whatever the project does. It shows up as a green test named after a feature, so a reader believes the feature is covered when no line of it runs. Coding agents write this kind of test when they cannot get a real one to pass.

What Skylos flags

test_provider.py · PythonReported on line 4
from billing.providers import infer_provider  def test_provider_inferred_from_claude_model():    model = "claude-3-7-sonnet-latest"    if "claude" in model.lower():        provider = "anthropic"    else:        provider = "openai"    assert provider == "anthropic"  def test_provider_inferred_from_gpt_model():    assert infer_provider("gpt-4.1") == "openai"

What Skylos leaves alone

test_provider.py · Python
from billing.providers import DEFAULT_MODEL, infer_provider  def test_provider_inferred_from_claude_model():    assert infer_provider("claude-3-7-sonnet-latest") == "anthropic"  def test_default_model_is_supported():    model = DEFAULT_MODEL    assert model.startswith("gpt-")

Why Skylos leaves it alone

The first test calls infer_provider; the second reads DEFAULT_MODEL, a name imported from the project. Either one can change the result, so neither test is reported.

How Skylos decides

  1. Runs with --quality. Looks only at tests pytest or unittest would collect: module-level test* functions and test* methods of collected Test* classes or proven unittest.TestCase subclasses, using the project's pytest settings. Skipped and xfail tests are left out.
  2. Reports the test when every name it reads is bound inside the test or is a builtin from a fixed list (len, sum, sorted, str, int, isinstance, range, ...) that still resolves to the builtin in that scope.
  3. Leaves the test alone when it takes a parameter (a fixture), has a decorator, imports anything, reads a module-level name, reads a self attribute other than a standard unittest assertion method, defines a nested function or class, raises, awaits or yields.
  4. A test with no assertion at all is also left alone when fixtures, setup hooks or a conftest.py may supply its checks.
  5. Empty bodies stay SKY-L041 and literal-only assertions such as assert True stay SKY-L040, so one test is not reported twice.

How to fix it

Call the code under test and assert on what it returns. Delete the copy of the logic from the test.

test_provider.py · Python · the fix, against the flagged file
from billing.providers import infer_provider  def test_provider_inferred_from_claude_model():Removed:     model = "claude-3-7-sonnet-latest"Removed:     if "claude" in model.lower():Removed:         provider = "anthropic"Removed:     else:Removed:         provider = "openai"Removed:     assert provider == "anthropic"Added:     assert infer_provider("claude-3-7-sonnet-latest") == "anthropic"  def test_provider_inferred_from_gpt_model():    assert infer_provider("gpt-4.1") == "openai"

When it can be wrong

  • A test of Python itself, or of a pure builtin, is reported: it really runs no project code. Move it out of the project's suite or suppress it.
  • It misses a test that calls project code and then ignores the result, or asserts the wrong value. SKY-L046 covers a result that is never checked; skylos done (SKY-A120) runs the tests to find lines no test would notice breaking.

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 def line of the test.

    Python
    def test_sorting_is_stable():  # skylos: ignore[SKY-L044] documents sorted()
  • [tool.skylos] ignore = ["SKY-L044"] turns the rule off for the project.

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