Skip to content

Commit a82d918

Browse files
davidparssonclaude
andcommitted
ci: Add root conftest.py to fix coverage under pytest
Isolates whether a root conftest.py (which puts the repo root on sys.path early, before coverage resolves --cov=injector) makes plain `pytest --cov=injector` measure the working-tree copy the tests run. DIAG print is temporary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5a44885 commit a82d918

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,7 @@ jobs:
3434
pip install .
3535
- name: Run tests
3636
run: |
37-
site_packages=$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))')
38-
# --- TEMP DIAGNOSTICS ---
39-
echo "DIAG PWD=$PWD"
40-
echo "DIAG site_packages=$site_packages"
41-
printf 'import sys\ndef pytest_collection_finish(session):\n m = sys.modules.get("injector")\n print("DIAG executed-injector:", getattr(m, "__file__", m))\n print("DIAG sys.path head:", sys.path[:6])\n' > conftest.py
42-
# --- END TEMP ---
43-
pytest -vv --cov="$PWD/injector" --cov="$site_packages/injector" --cov-branch --cov-report html --cov-report term || true
44-
# --- TEMP DIAGNOSTICS ---
45-
python -c "import coverage; d=coverage.CoverageData(); d.read(); print('DIAG measured:', list(d.measured_files()))" || true
46-
rm -f conftest.py
47-
# --- END TEMP ---
37+
pytest -vv --cov=injector --cov-branch --cov-report html --cov-report term
4838
if which mypy; then mypy injector ; fi
4939
if which black; then black --check . ; fi
5040
check-manifest

conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import sys
2+
3+
4+
def pytest_collection_finish(session):
5+
m = sys.modules.get("injector")
6+
print("DIAG executed-injector:", getattr(m, "__file__", m))

0 commit comments

Comments
 (0)