Skip to content

PY-TEST0015 · duplicate_test_intent_cluster_count

Count tests that repeat the same body, data, fixtures, and production reach.

This is a deterministic rule for python. Read its implementation.

Resolve every collected test through the repository call graph. Follow test helpers until the graph reaches production declarations, then group tests only when their complete reachable declaration set, literal-neutral body, literal vector, and fixture closure are identical. A group containing at least minimum_tests tests is one duplicate intent cluster.

Each finding names every duplicate test and reports the test count and shared production graph point count. The default requires two exact duplicates. The value is the number of clusters, not the number of tests in them.

Tests with no statically reachable production declaration abstain. Different literals, fixtures, assertion structure, control flow, or reachable declarations keep tests separate. Dynamic dispatch can leave a static graph incomplete, so this rule never deletes a test and offers no automatic repair.

Bad

Two parser tests have the same body, values, fixtures, and reachable production declarations,
so they form `1` cluster.
Good

An invalid-input test expects a different result and reaches the parser error path, so it stays separate and the duplicate cluster value is 0.

  • Cites “xUnit Test Patterns”, test code duplication
  • Cites “Growing Object-Oriented Software, Guided by Tests”, maintaining test intent