SKY-L047 · Logic and resilience
Duplicate test
A test with the same decorators, parameters and body as an earlier test in the same module or class, under a different name. Docstrings and layout are ignored; one changed literal makes it a different test.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
The copy adds run time and checks nothing new. Its name usually promises a different case, such as ..._when_meaningful_test_file_changed next to ..._when_any_test_file_changed, and that case stays untested.
What Skylos flags
from review.impact import detect_gaps def test_allows_change_when_any_test_file_changed(): changed = ["src/billing/tax.py", "tests/test_tax.py"] findings = detect_gaps(changed) assert findings == [] def test_allows_change_when_meaningful_test_file_changed(): changed = ["src/billing/tax.py", "tests/test_tax.py"] findings = detect_gaps(changed) assert findings == []What Skylos leaves alone
import pytest from review.impact import detect_gaps def test_allows_change_when_any_test_file_changed(): findings = detect_gaps(["src/billing/tax.py", "tests/test_tax.py"]) assert findings == [] def test_reports_change_without_tests(): findings = detect_gaps(["src/billing/tax.py"]) assert findings != [] @pytest.mark.vcr()def test_first_recorded_run(): assert detect_gaps(["src/billing/tax.py"]) != [] @pytest.mark.vcr()def test_second_recorded_run(): assert detect_gaps(["src/billing/tax.py"]) != []Why Skylos leaves it alone
The first two tests pass different inputs. The last two have the same body, but vcr replays a recording chosen by the test's name, so they can run against different data.
How Skylos decides
- Runs with
--qualityon the same collected tests as SKY-L044, comparing tests of the same module, or of the same class, never across classes. - Two tests match when their parameters, decorators and statements are identical as syntax trees, apart from a leading docstring. The later one is reported and names the first.
- Skips bodies that call nothing, a second definition under the same name (Python keeps only the last), and tests whose name selects recorded data: a
vcr,cassette,betamaxorrecordingmarker, or asnapshot,vcr_cassette,requestor regression fixture.
How to fix it
Remove the copy, or change it to cover the case its name describes.
from review.impact import detect_gaps def test_allows_change_when_any_test_file_changed(): changed = ["src/billing/tax.py", "tests/test_tax.py"] findings = detect_gaps(changed) assert findings == [] Removed: def test_allows_change_when_meaningful_test_file_changed():Removed: changed = ["src/billing/tax.py", "tests/test_tax.py"]Added: def test_reports_change_when_test_file_only_adds_comments():Added: changed = ["src/billing/tax.py", "tests/test_tax_comments.py"] findings = detect_gaps(changed)Removed: assert findings == []Added: assert findings != []When it can be wrong
- Two tests that read different data through a fixture or plugin keyed on the test name Skylos does not know are reported as copies.
- It misses copies that differ only in a variable name or a comment-only line move, and copies in different classes or files.
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
defline of the later test.Python def test_meaningful_change(): # skylos: ignore[SKY-L047] other cassette[tool.skylos] ignore = ["SKY-L047"]turns the rule off for the project.