From 36facdc15c325cb8c38a24ffcaa53b357d2dffef Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 19:47:57 +0000 Subject: [PATCH] CI: start coverage before pytest loads dandi's plugin dandi's pytest plugin is registered as a pytest11 entry point, and pytest loads those before pytest-cov starts measuring. The plugin imports dandi.tests.fixtures and thus most of dandi, so all module-level lines (imports, def/class lines, decorators) were reported as uncovered, e.g. misctypes.py at 0% when running test_pynwb_utils.py alone, 56.6% when measured from the start. Run pytest under 'coverage run' instead, as tox.ini already does, and combine the parallel data files it writes (parallel = True in tox.ini) before producing coverage.xml. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Qn5WBSiQgoZoL4fytF6nEr --- .github/workflows/run-tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fec7c9104..948b34353 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -142,8 +142,12 @@ jobs: - name: Run all tests except those involving obolibrary if: matrix.mode != 'dandi-api' && matrix.mode != 'obolibrary-only' && matrix.mode != 'lowest-deps' + # Start coverage before pytest, which loads dandi's pytest plugin (and + # thus imports most of dandi) before pytest-cov would start it run: | - python -m pytest -s -v -m "not obolibrary" --cov=dandi --cov-report=xml dandi + python -m coverage run -m pytest -s -v -m "not obolibrary" dandi + python -m coverage combine + python -m coverage xml - name: Run tests against minimum declared dependency versions if: matrix.mode == 'lowest-deps' @@ -168,7 +172,9 @@ jobs: if: matrix.mode == 'dandi-api' run: | export DANDI_TESTS_AUDIT_CSV=/tmp/audit.csv - python -m pytest -s -v --cov=dandi --cov-report=xml --dandi-api dandi + python -m coverage run -m pytest -s -v --dandi-api dandi + python -m coverage combine + python -m coverage xml if [ ! -e /tmp/audit.csv ] then echo Audit file not created exit 1