Skip to content

restated-test-docstring

Collected test docstring only repeats names and visible code.

Why

A docstring that narrates visible test code creates duplicate prose that can drift without explaining the regression or contract.

Fix

Delete only the restatement and put the scenario and expected outcome in the test name. Keep concise non-obvious regression, constraint, or contract context in the docstring or a local comment.

Examples

Before — flagged Docstring repeats the test name
tests/test_widget.py
def test_widget_renders():
"""Verify that the widget renders correctly."""
assert render(widget)
After — preferred Docstring records a hidden failure mode
tests/test_widget.py
def test_widget_renders():
"""Without the stable key, retries would render the widget twice."""
assert render(widget)