PYTHON-5753 Add just recipes for running coverage tests locally
This commit is contained in:
parent
3d89d9faca
commit
a80d0ad4c3
@ -205,6 +205,7 @@ the pages will re-render and the browser will automatically refresh.
|
||||
and the `<class_name>` to test a full module. For example:
|
||||
`just test test/test_change_stream.py::TestUnifiedChangeStreamsErrors::test_change_stream_errors_on_ElectionInProgress`.
|
||||
- Use the `-k` argument to select tests by pattern.
|
||||
- Run `just test-coverage` to run tests with coverage and display a report. Use `just coverage-html` to generate an HTML report in `htmlcov/index.html`.
|
||||
|
||||
|
||||
## Running tests that require secrets, services, or other configuration
|
||||
|
||||
29
justfile
29
justfile
@ -82,6 +82,35 @@ teardown-tests:
|
||||
integration-tests:
|
||||
bash integration_tests/run.sh
|
||||
|
||||
[group('test')]
|
||||
test-coverage *args="":
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ -n "${USE_ACTIVE_VENV:-}" ]; then
|
||||
# When USE_ACTIVE_VENV is set, run coverage directly in the active venv
|
||||
uv run --active --extra test --group coverage python -m coverage run -m pytest {{args}}
|
||||
uv run --active --group coverage python -m coverage report
|
||||
else
|
||||
# Otherwise use the standard Evergreen workflow
|
||||
just setup-tests --cov
|
||||
just run-tests {{args}}
|
||||
just coverage-report
|
||||
fi
|
||||
|
||||
[group('coverage')]
|
||||
coverage-report:
|
||||
uv tool run --with "coverage[toml]" coverage report
|
||||
|
||||
[group('coverage')]
|
||||
coverage-html:
|
||||
uv tool run --with "coverage[toml]" coverage html
|
||||
@echo "Coverage report generated in htmlcov/index.html"
|
||||
|
||||
[group('coverage')]
|
||||
coverage-xml:
|
||||
uv tool run --with "coverage[toml]" coverage xml
|
||||
@echo "Coverage report generated in coverage.xml"
|
||||
|
||||
[group('server')]
|
||||
run-server *args="":
|
||||
bash .evergreen/scripts/run-server.sh {{args}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user