Skip to main content

SKY-L041 · Logic and resilience

Empty test body

Low

A collected test whose body is only a docstring, pass or .... Its name promises a check that was never written.

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

pytest reports the empty test as passed, so the suite looks complete. Generated test files often contain a row of such stubs, and nobody notices that refunds were never tested.

What Skylos flags

tests/test_refunds.py · PythonReported on line 1
def test_refund_restores_stock():    """Refunding an order puts its items back in stock."""    pass

What Skylos leaves alone

tests/test_refunds.py · Python
import pytest  @pytest.mark.skip(reason="needs the warehouse stub")def test_refund_restores_stock():    """Refunding an order puts its items back in stock."""    pass

Why Skylos leaves it alone

The test is marked skip with a reason, so pytest reports it as skipped rather than passed and the gap shows up in every test run. Skylos leaves skipped and xfail tests alone.

How Skylos decides

  1. Runs with --quality on Python test files that pytest would collect under the project's settings (test_*.py and *_test.py by default) and on proven unittest.TestCase classes. Skipped and xfail tests, conftest.py and fixture folders are left out.
  2. Reports a test whose body, after an optional docstring, holds only pass or ....
  3. Skips a test that takes parameters (fixtures can carry the checks), and every test in a file or class where fixtures could do the checking: a usefixtures mark, an autouse fixture in the module, a setup or teardown hook such as setUp, setup_method or setup_module, or a conftest.py in the test's folder or above.
  4. Reports LOW on the def line.

How to fix it

Write the check the name describes, or delete the stub. If it must wait, mark it skip with a reason, as in the example Skylos leaves alone.

tests/test_refunds.py · Python · the fix, against the flagged file
Added: from shop.orders import place_order, refundAdded: from shop.stock import stock_levelAdded:  Added:  def test_refund_restores_stock():    """Refunding an order puts its items back in stock."""Removed:     passAdded:     order = place_order(sku="MUG-1", quantity=2)Added:     refund(order)Added:     assert stock_level("MUG-1") == 10

When it can be wrong

  • A test that exists only to prove a module imports cleanly is reported when its body is pass. A plain import at the top of the file already does that.
  • It misses stubs that take a fixture parameter, since the fixture may hold the real checks.

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.

    Python
    def test_refund_restores_stock():  # skylos: ignore[SKY-L041] placeholder
  • [tool.skylos] ignore = ["SKY-L041"] turns the rule off for the project.

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