Skip to content

repeated-kwarg-heavy-call-in-test

Tests repeat at least seven explicit keyword names across calls to the same callee.

Why

Large repeated argument lists duplicate incidental setup, bury scenario differences, and make signature changes noisy within a test file.

Fix

Extract a scenario helper with sensible defaults, or use a parametrized case table, and override only values relevant to each case. Suppress the finding when every argument intentionally specifies the contract, an ordered state transition, or a retry.

Examples

Before — flagged Tests repeat incidental order setup
tests/test_call.py
def test_pending_order():
request = CreateOrderRequest(
organization_id="org-1",
actor_id="user-1",
currency="SAR",
locale="ar-SA",
channel="web",
notify_customer=True,
retry_limit=3,
status="pending",
)
assert request.status == "pending"
def test_completed_order():
request = CreateOrderRequest(
organization_id="org-1",
actor_id="user-1",
currency="SAR",
locale="ar-SA",
channel="web",
notify_customer=True,
retry_limit=3,
status="completed",
)
assert request.status == "completed"
After — preferred Tests keep incidental order defaults in one helper
tests/test_call.py
ORDER_DEFAULTS = {
"organization_id": "org-1",
"actor_id": "user-1",
"currency": "SAR",
"locale": "ar-SA",
"channel": "web",
"notify_customer": True,
"retry_limit": 3,
}
def make_order(status):
return CreateOrderRequest(**ORDER_DEFAULTS, status=status)
def test_pending_order():
assert make_order("pending").status == "pending"
def test_completed_order():
assert make_order("completed").status == "completed"

Formerly: kwarg-heavy-construction-in-test