Skip to content

Slim the Python test suite by a third (coverage unchanged) - #328

Merged
lbx154 merged 4 commits into
devfrom
chore/slim-tests
Oct 24, 2026
Merged

lbx154 merged 4 commits into
devfrom
chore/slim-tests

Conversation

@lbx154

@lbx154 lbx154 commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Cuts the Python test suite by about a third while keeping argus/ line coverage the same. No source file changes.

Numbers (origin/dev 5ebebb5 vs this branch)

before after
tests/**/*.py lines 180,717 119,001 (−61,716, −34.2%)
test files 758 710 (48 deleted, ~530 trimmed)
test functions 6,974 ~3,900 (3,066 removed)
line coverage of argus/ 84.737% (74,516 / 87,938) 84.752% (74,529 / 87,938)
branch coverage (pre-merge base, --cov-branch) 23,394 / 30,708 branches 23,397 / 30,708
full suite, -n 16, no coverage 97 s 68 s
full suite, -n 16, with coverage 124 s 112 s

Coverage went up by noise (+0.015 pt): the removed tests cover no line or branch that the remaining suite misses.

How tests were chosen

  1. Ran the whole suite with --cov-context=test --cov-branch, so every test has its own set of argus/ lines and branch arcs.
  2. A test function (all its parametrized cases together) could only be removed if each of its lines and branches is still covered by a test that stays. Two passes:
    • Copy-paste variants first: tests whose lines and branches are all covered by another test in the same file. This pass covers 1,912 functions and ~30k lines.
    • Then cross-file duplicates: tests fully covered by tests in other files. Largest first, and tests added in the last week are skipped in this pass.
  3. Never candidates:
    • tests/release_tools/
    • files added since 2026-10-23
    • test_review_once.py, test_effort_policy.py, test_liveness_operator.py, webapi/test_canvas*.py, webapi/test_map_trace_relations.py
    • every conftest.py
    • static/structural checks (architecture, invariants, packaging, frozen runtime, docs)
    • any test whose body mentions an incident, regression, trial, bug, reproduction, session id, issue number or a date (669 functions)
    • tests that touch fewer than 5 argus/ lines (they check files outside argus/)
  4. After removal, module helpers, fixtures (except autouse ones) and constants that nothing references any more were removed, and ruff --fix cleaned up imports. A file is deleted only when it has no tests left and no other test imports from it.

What was removed, by kind:

  • Near-identical variants that hit the same code path with different literals.
  • Several tests over the same function where one already covers every branch.
  • Unit tests of private helpers that a public-behavior test already drives through the same branches.
  • Whole files for features whose code paths are fully exercised elsewhere.

Removed lines by directory (approx.):

  • tests/ root: 11.6k
  • life: 11.6k
  • webapi: 8.8k
  • core: 7.8k
  • skills: 4.2k
  • manager: 4.2k
  • trial: 3.2k
  • daemon: 2.4k
  • apps: 2.2k
  • other: ~5k

One small test fix: webapi/test_workspace_v2.py::test_workspace_git_portable_pipe_reads_are_bounded_and_reaped monkeypatches subprocess.Popen globally and counted a spawn from another test's leftover thread once when test order changed. It now counts only spawns from its own thread.

Checks

  • Full suite green on this branch: -n 16, with coverage.
  • tests/trial/test_gateway* concurrency tests fail now and then under -n 16 load on both dev and this branch. They pass on both with -p no:xdist.
  • ruff check argus tests is clean.
  • Scenario eval (--code this branch, run 20261024-110351): 19/20 on the first run. The miss was k1-split-cents (checks 6/7), and it is not caused by this PR: the branch changes no file outside tests/, so the Argus code is byte-identical to dev. In that run the team asked about rounding and negatives, the operator answered "negatives and >2 decimals raise ValueError", and the delivered code used the team's own first proposal instead. Rerunning only k1 (run 20261024-112139) passed 7/7, 0 oddities. That makes it 20/20 across the two runs. The ignored answer looks like a real product flake on dev and is worth its own look.

Merge after review; no source or release artifacts touched.

🤖 Generated with Claude Code

lbx154 and others added 4 commits October 24, 2026 11:03
…ther tests

Selected from per-test coverage (--cov-context=test, branch mode): each file's
tests cover no argus/ line or branch that the remaining suite does not.
Files added since 2026-10-23, release_tools, canvas and named-regression tests
were never candidates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removes copy-paste variants first (all lines and branches covered by a sibling
in the same file), then tests fully covered elsewhere; tests that mention an
incident, regression, trial, bug or dated finding, and tests added in the last
week, are kept. Helpers and imports left unused are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aemon

Same selection rule as the life/core batch. Also stops the Popen-counting test in
test_workspace_v2 from counting a spawn made by another test's leftover thread
(it failed once in a full run when ordering changed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same selection rule: only tests whose lines and branches stay covered by the
rest of the suite; recent, named-regression and protected files untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lbx154
lbx154 merged commit c5cc72f into dev Oct 24, 2026
5 of 6 checks passed
@lbx154
lbx154 deleted the chore/slim-tests branch October 24, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant