Skip to content

Commit 36facdc

Browse files
committed
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qn5WBSiQgoZoL4fytF6nEr
1 parent 8b6a1fc commit 36facdc

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎.github/workflows/run-tests.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ jobs:
142142

143143
- name: Run all tests except those involving obolibrary
144144
if: matrix.mode != 'dandi-api' && matrix.mode != 'obolibrary-only' && matrix.mode != 'lowest-deps'
145+
# Start coverage before pytest, which loads dandi's pytest plugin (and
146+
# thus imports most of dandi) before pytest-cov would start it
145147
run: |
146-
python -m pytest -s -v -m "not obolibrary" --cov=dandi --cov-report=xml dandi
148+
python -m coverage run -m pytest -s -v -m "not obolibrary" dandi
149+
python -m coverage combine
150+
python -m coverage xml
147151
148152
- name: Run tests against minimum declared dependency versions
149153
if: matrix.mode == 'lowest-deps'
@@ -168,7 +172,9 @@ jobs:
168172
if: matrix.mode == 'dandi-api'
169173
run: |
170174
export DANDI_TESTS_AUDIT_CSV=/tmp/audit.csv
171-
python -m pytest -s -v --cov=dandi --cov-report=xml --dandi-api dandi
175+
python -m coverage run -m pytest -s -v --dandi-api dandi
176+
python -m coverage combine
177+
python -m coverage xml
172178
if [ ! -e /tmp/audit.csv ]
173179
then echo Audit file not created
174180
exit 1

0 commit comments

Comments
 (0)