Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does just coverage-html require just test-coverage to be run first? We should make that clear if so.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done



## Running tests that require secrets, services, or other configuration
Expand Down
29 changes: 29 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor Author

@aclark4life aclark4life Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to make a follow up ticket PYTHON-5754 makes setup-tests run-tests support USE_ACTIVE_VENV so this could potentially wait for that to be done and then we can remove this conditional statement.

just setup-tests --cov
just run-tests {{args}}
just coverage-report

This comment was marked as resolved.

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}}
Expand Down
Loading