Add test suite: 92% coverage on the core library#6
Conversation
|
The four fix PRs (#2–#5) are now merged into main — thanks again for the whole series, this is exactly the kind of contribution we hope for. Could you rebase this branch on main so it shows just the test additions + coverage config? We're also setting up CI shortly, so this suite will become the merge gate for the repo. We'll review right after the rebase. |
Avo-k
left a comment
There was a problem hiding this comment.
Security pass + full review done — this is a great suite. The claims check out exactly on our side: 92% coverage measured, 211 tests green in ~7s on a local merge with main, everything runs without the heavy ML deps. The mock hygiene (hermetic httpx / sentence-transformers fakes, everything under tmp_path) made the audit easy.
Two small changes before merge — and if you prefer, we're happy to apply both ourselves at merge time, just say the word:
test_gpu_memory_stats_raises_importerror_without_torchfails when torch is installed (it assertsImportError, but a full dev env has torch). A conditional skip would fix it, e.g.@pytest.mark.skipif(importlib.util.find_spec("torch") is not None, reason="torch installed")._inject_fake_sentence_transformers(test_metrics_extra.py) assignssys.modules["sentence_transformers"]directly and never restores it, so the fake can leak into any later test that imports the real package.monkeypatch.setitem(sys.modules, "sentence_transformers", st)keeps it scoped per-test.
Two notes, no action needed in this PR:
- Your
test_merge_with_existing_parquettests correctly characterize a real duplication quirk in the*_from_dfmerge path — nice catch. Opened #8 to fix it source-side; once that lands, those assertions can tighten. - Heads-up for the rebase (still needed — the branch predates today's main): main now has a CI workflow (
.github/workflows/ci.yml) and a[test]extra in pyproject, so you'll see small conflicts there. After the rebase, this PR's CI runs should be green out of the box except the two points above.
Adds pure-logic and mockable tests across splitters, postprocessing (incl. the *_from_df drivers), metrics (fake embedding model, mocked sentence-transformers, real sklearn), jina_embedder (mocked httpx), pipeline (fake parser), and the split/metrics/mentions directory drivers (fake splitters/models, parquet fixtures). Adds a coverage config scoping the target to the importable library and excluding paper/ (research replication scripts) and parsing.py (thin adapters over heavy optional SDKs: Azure DI / Docling / PyMuPDF). On that scope coverage is 92% (was ~19%); the remaining gap is the spaCy/maverick coref internals in metrics.py, which need real models to exercise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
split_documents, compute_metrics, postprocessing (*_from_df) and extract_mentions all read/write .parquet via pandas, but pandas>=2.2 does not pull a parquet engine automatically, so these functions (and their tests) fail at runtime without one. Add pyarrow as an explicit dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ce_transformers via monkeypatch Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a00e736 to
025ae6f
Compare
Brings the importable core library from ~19% to 92% test coverage, and adds a coverage config that scopes the target sensibly.
What's added
Pure-logic and mockable tests (no heavy ML deps, no network, no model downloads):
group_chunks/group_pages/combine_blocks/regex_splitter.*_from_dfdrivers with tiny parquet fixtures.sentence_transformersmocked viasys.modules, realscikit-learnfor the lexical metric, and the pure coref helpers.httpxmocked.chunk_filesend-to-end with a fake parser.Coverage config (
[tool.coverage]in pyproject)Scopes measurement to the library and omits:
paper/*— one-off research replication scripts, not part of the API.parsing.py— thin adapters over Azure DI / Docling / PyMuPDF, which are heavy optional dependencies needing model downloads (still exercised bytest_parsing.py, just not measured).The remaining uncovered gap is the spaCy/maverick coreference internals in
metrics.py(extract_entity_pronoun_pairs,CoreferenceSolver.__init__/find_mentions), which require real models to run.Result
pytest: 211 passed, 1 skipped; 92% on the scoped target.🤖 Generated with Claude Code