Description
Improve unit/integration test coverage so that test/ stands on its own — without leaning on docs/examples/ as accidental test infrastructure.
Background in Discussion #811.
Why bother
HPC coverage from test/ alone (all backends, 1034 tests): 63.9% line, 51.8% branch. Several areas have near-zero test/ coverage and are only exercised by print-only examples or e2e suites behind GPU gates. Much of that code is deterministic parsing, validation, and serialisation — straightforward to unit test, no model required.
Once properly covered in test/, examples become what they should be: runnable docs, not load-bearing test infrastructure.
Coverage baseline (LSF/HPC run, 2026-04-10, most tests running)
Reasonably covered (>75%):
| Area | Stmts | Miss | Cov% |
|---|---|---|---|
formatters/ (non-granite) |
159 | 8 | 95.0 |
core/ |
636 | 61 | 90.4 |
backends/adapters/ |
95 | 13 | 86.3 |
plugins/ |
651 | 92 | 85.9 |
telemetry/ |
389 | 58 | 85.1 |
stdlib/sampling/ |
567 | 90 | 84.1 |
stdlib/components/ |
911 | 181 | 80.1 |
backends/ (core 5) |
1415 | 286 | 79.8 |
Under-covered — pure logic, no backend needed:
| Area | Stmts | Miss | Cov% | Notes |
|---|---|---|---|---|
formatters/granite/ |
2347 | 1128 | 51.9 | Biggest gap by far. Deterministic string transforms, fully testable with fixtures. |
stdlib/requirements/ |
361 | 208 | 42.4 | Pydantic models, validation logic |
stdlib/components/unit_test_eval |
71 | 71 | 0.0 | Pure Pydantic + JSON, used by eval CLI |
stdlib/frameworks/react.py |
39 | 39 | 0.0 | Partially testable with mock backend |
Under-covered — backend-dependent (not worth pursuing):
| Area | Stmts | Miss | Cov% | Notes |
|---|---|---|---|---|
backends/vllm.py |
— | — | — | Removed from codebase |
backends/watsonx.py |
241 | 203 | 15.8 | Deprecated (use LiteLLM or OpenAI instead) |
backends/bedrock.py |
42 | 32 | 23.8 | Gated behind credentials not available in CI |
No point investing test effort in removed or deprecated code. Bedrock is small (42 stmts) but has testable pure logic (URI construction, ModelIdentifier matching, env var validation) — included in #816.
Excluded from coverage work: stdlib/requirements/safety/guardian.py (157 stmts, 0%) — deprecated in favour of Guardian Intrinsics. Not worth the investment.
Children
| Area | Issue | Tests | Status |
|---|---|---|---|
| Granite formatters (3.2, 3.3, intrinsics) | #812 | ~199 | ✅ Closed |
| stdlib/requirements (tool_reqs, requirement, md) | #814 | ~28 | ✅ Closed |
| helpers (openai_compatible_helpers, async_helpers) | #815 | ~24 | ✅ Closed |
| Backend pure logic (cache, catalog, bedrock) | #816 | ~18 | ✅ Closed |
| stdlib components (react, unit_test_eval) | #817 | ~21 | ✅ Closed |
| Coverage wrap-up — remaining pure-logic gaps | #860 | ~300 | ✅ Closed (PR #862 merged 2026-04-15) |
| CLI pure-logic helpers (decompose, eval) | #861 | 37 | ✅ Closed (PR #863 merged 2026-04-15) |
Principles
- Prioritise deterministic parsing, serialisation, and validation — high regression value, no model needed
- Use canned data from existing
testdata/where available - All tests auto-receive
unitmarker, run in the defaultpytestinvocation - Don't duplicate e2e/qualitative coverage — mocking risk is real, test behaviour not implementation details
Part of #726. Complements #729 (splitting existing e2e tests into lighter variants) — this issue covers gaps where no test existed at all. Progress tracking depends on #737 (coverage reporting) to give us ongoing visibility of where we stand.
Activity
planetf1 commentedon Apr 14, 2026
Coverage snapshot — 2026-04-14
Reran unit/integration tests locally (same filter:
not qualitative and not e2e and not ollama and not hf and not openai and not watsonx and not litellm and not slow) to measure progress since the baseline.Overall
Gains by area
helpers/formatters/granite/stdlib/requirements/stdlib/components/backends/adapters/core/plugins/backends/(core 5)Next steps — high-value pure-logic targets
Files with meaningful statement counts, low coverage, and no backend dependency:
stdlib/functional.pystdlib/components/genstub.pystdlib/session.pystdlib/sampling/majority_voting.pystdlib/sampling/budget_forcing.py+budget_forcing_alg.pystdlib/components/simple.pystdlib/components/instruction.pystdlib/components/chat.pyformatters/granite/base/util.pytelemetry/tracing.pyProbably skip
backends/ollama.py,huggingface.py,openai.py,litellm.py,watsonx.pyformatters/granite/retrievers/(elasticsearch, embeddings, util — 190 stmts, 0%)stdlib/requirements/safety/guardian.py(157 stmts, 0%)backends/watsonx.pystdlib/sampling/budget_forcing_alg.pyplanetf1 commentedon Apr 15, 2026
Coverage snapshot — 2026-04-15
Second wave of pure-logic tests on branch
test/coverage-gaps-813(#860). Same local filter as previous snapshot (not qualitative and not e2e and not ollama/hf/openai/watsonx/litellm/slow).Overall
Gains by area
helpers/formatters/granite/stdlib/requirements/guardian.py(157 stmts, deprecated) is the entire remaining gapstdlib/components/stdlib/sampling/backends/adapters/backends/(all)core/plugins/telemetry/Ceiling analysis
Pure-logic coverage is now essentially maxed out. Remaining uncovered code in each area:
stdlib/requirements/(54.7%): 157-stmtguardian.py(deprecated) is the entire gap. Without it: ~88%.stdlib/components/(76.9%): Remaining isSyncGenerativeStub.__call__()execution path (needs mock-backend) + model-gated intrinsics (guardian, rag).stdlib/sampling/(59.3%):budget_forcing(132 stmts) callsbackend.generate_from_raw()directly.majority_voting.sample()is the async sampling loop.plugins/(86.2%): cpex optional-dependency registration — only runs when cpex installed.telemetry/(84.8%): OTelTracerProvider/BatchSpanProcessorbootstrap — only runs when OTEL configured.backends/(38.3%): Generate/stream/post-process paths all require live backend connections.Cumulative progress since 2026-04-10
Remaining work
test: add pure-logic unit tests for stdlib, core, backends, telemetry
planetf1 commentedon Apr 15, 2026
Combined coverage snapshot — PRs #862, #863, #845
Measured on a local branch combining all three open PRs (cherry-picked onto `upstream/main`). Filter: unit + integration tests, no live backends (same basis as the 47.8% baseline).
Progression
Total improvement: +15.4pp from the baseline.
Previously under-covered areas
formatters/granite/stdlib/requirements/stdlib/components/unit_test_evalstdlib/frameworks/react.pycli/decompose/cli/eval/Caveat
backends/shows lower coverage locally (37%) than in the HPC baseline (79.8%) because live-backend tests are excluded from the local filter. The overall 63.2% figure is directly comparable to the 47.8% baseline — both use the same test scope. A full HPC run after merge will give the definitive combined figure.planetf1 commentedon Apr 15, 2026
The 76.5% figure for `formatters/granite/` is likely to improve further in the next iteration. Issue #827 specifically tracks expanding the granite formatter tests with additional edge cases and alignment with the upstream granite-common test suite. That work is not included in the PRs above.
test: pure-logic unit tests for stdlib, core, backends, telemetry (#860…
planetf1 commentedon Apr 24, 2026
All child issues are now closed:
Closing as completed.
test: pure-logic unit tests for stdlib, core, backends, telemetry (ge…