Skip to content

Commit ecf9685

Browse files
GeekTrainerCopilot
andcommitted
ci(validate): install pytest and gate python suites on real test files
The build-and-test job failed with "No module named pytest": the Python step ran `python -m pytest` but only `pip install -e services/<svc>`, which omits pytest (declared in the service's `dev` extra). It also ran pytest whenever a tests/ dir existed, but early modules ship a tests/ dir with only a README, so pytest would exit 5 (no tests collected). Only run pytest when real test files (test_*.py / *_test.py) are present, and in that case install the dev extra (pins pytest/pytest-asyncio) with a direct pytest install as a fallback so `python -m pytest` is always available. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3750cefd-d322-4f02-9184-c8ac3eba2fff
1 parent d7520d7 commit ecf9685

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

course-build/scripts/validate-branch.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,18 @@ echo "==> Java services build (all on Java 21; audit/auth target Java 17 bytecod
7777
echo "==> Python services install + pytest"
7878
for svc in reporting-svc notifications-svc; do
7979
if [ -f "services/$svc/pyproject.toml" ]; then
80-
pip install -e "services/$svc"
81-
if [ -d "services/$svc/tests" ]; then ( cd "services/$svc" && python -m pytest -q ); fi
80+
# Early modules ship a tests/ dir containing only a README; real test files
81+
# (test_*.py / *_test.py) appear from M03 onward. Only run pytest when they exist,
82+
# otherwise just verify the service is installable.
83+
if ls "services/$svc"/tests/test_*.py "services/$svc"/tests/*_test.py >/dev/null 2>&1; then
84+
# Install the dev extra (pins pytest/pytest-asyncio) when declared, and guarantee
85+
# pytest is importable so `python -m pytest` never fails with "No module named pytest".
86+
pip install -e "services/$svc[dev]"
87+
python -c "import pytest" 2>/dev/null || pip install pytest pytest-asyncio
88+
( cd "services/$svc" && python -m pytest -q )
89+
else
90+
pip install -e "services/$svc"
91+
fi
8292
fi
8393
done
8494

0 commit comments

Comments
 (0)