Background
Overall test coverage is ~33% (4,525 / 13,801 statements). The largest untested modules were assessed in March 2026. Two modules have 0% coverage and are good near-term targets. Two megaclass modules are feasible but require shared fixture infrastructure first.
Priority targets
| Module |
Statements |
Coverage |
Barrier |
tools/permutation.py |
236 |
0% |
Pure numerical logic; needs AnnData + spatial graph fixture |
spatialdata/_convert.py |
261 |
0% |
Conversion layer; needs round-trip InSituPy ↔ SpatialData fixture |
_core/data.py |
731 |
26% |
Core InSituData class; needs shared fixture |
experiment/data.py |
947 |
14% |
Multi-sample container; needs shared fixture |
Skip for now: interactive/_widgets.py and interactive/_transcript_viewer.py — both require a live napari/Qt display context.
What needs to be done
- Build a shared fixture in
tests/conftest.py — a minimal but real InSituData object (and optionally a small InSituExperiment) constructed once per session:
@pytest.fixture(scope="session")
def insitudata_small():
# load smallest available test dataset or construct synthetically
...
- Cover
permutation.py — test the permutation null distribution logic with a small AnnData + precomputed neighbor graph.
- Cover
spatialdata/_convert.py — test round-trip conversion (InSituPy → SpatialData → InSituPy) for each element type (images, tables, annotations, transcripts, boundaries).
- Cover
_core/data.py and experiment/data.py using the shared fixture once it exists.
Implementation prompt
You are adding tests to the InSituPy package to improve coverage of four under-tested modules. Start by creating a shared session-scoped pytest fixture in tests/conftest.py that constructs a minimal InSituData object (use the smallest available test dataset or synthetic data). Use the conda environment isp012 to run pytest.
Then implement tests in this order:
tests/test_tools_permutation.py — cover tools/permutation.py (236 stmts, 0%). Build a small AnnData with a precomputed neighbor graph and test the permutation null distribution logic.
tests/test_spatialdata_convert.py — cover spatialdata/_convert.py (261 stmts, 0%). Write round-trip conversion tests (InSituPy → SpatialData → InSituPy) for each supported element type.
tests/test_core_data.py — cover _core/data.py (731 stmts, 26%) using the shared insitudata_small fixture.
tests/test_experiment_data.py — cover experiment/data.py (947 stmts, 14%) using a shared InSituExperiment fixture wrapping multiple InSituData instances.
Run pytest --cov=insitupy --cov-report=json before and after to measure the coverage delta. Target: raise overall coverage above 45%.
Background
Overall test coverage is ~33% (4,525 / 13,801 statements). The largest untested modules were assessed in March 2026. Two modules have 0% coverage and are good near-term targets. Two megaclass modules are feasible but require shared fixture infrastructure first.
Priority targets
tools/permutation.pyspatialdata/_convert.py_core/data.pyInSituDataclass; needs shared fixtureexperiment/data.pySkip for now:
interactive/_widgets.pyandinteractive/_transcript_viewer.py— both require a live napari/Qt display context.What needs to be done
tests/conftest.py— a minimal but realInSituDataobject (and optionally a smallInSituExperiment) constructed once per session:permutation.py— test the permutation null distribution logic with a small AnnData + precomputed neighbor graph.spatialdata/_convert.py— test round-trip conversion (InSituPy → SpatialData → InSituPy) for each element type (images, tables, annotations, transcripts, boundaries)._core/data.pyandexperiment/data.pyusing the shared fixture once it exists.Implementation prompt