Python · testing
restated-test-docstring
python:restated-test-docstring Test docstrings must add information beyond the test name and body.
- Code
- SARJ088
- Default
- error
- Fix
- none
- Languages
- python
Why
A docstring that narrates visible test code creates duplicate prose that can drift without explaining the regression or contract.
Fix
Delete the redundant docstring, improve the test name, or document a reason or constraint not visible in the test.
Before / after
Executed by this rule’s unit tests.
Before
Docstring repeats the test name
def test_widget_renders():
"""Verify that the widget renders correctly."""
assert render(widget)
After
Docstring explains the regression
def test_keeps_the_lock():
"""The scheduler would spin forever without this."""
assert acquire()
Limits
- Only test functions and unbased Test-prefixed classes in recognized test files are checked.
- Structured, protected, value-bearing, generated, and genuinely novel docstrings are preserved.