Generate Coverage
How to Generate Coverage Reports
Section titled “How to Generate Coverage Reports”This guide shows you how to generate and view code coverage reports.
Generate Coverage for All Modules
Section titled “Generate Coverage for All Modules”-
Navigate to the API directory
Terminal window cd idx-api -
Generate coverage with HTML report
Terminal window make test-coverage -
Open the report in your browser
Terminal window open reports/coverage/index.html
Generate Coverage for Specific Modules
Section titled “Generate Coverage for Specific Modules”cd idx-api
# Coverage for agent router onlyuv run pytest tests/ --cov=idx_api.routers.agents --cov-report=html
# Coverage for multiple modulesuv run pytest tests/ \ --cov=idx_api.routers.agents \ --cov=idx_api.routers.brokerages \ --cov-report=html
# Coverage for entire package with terminal outputuv run pytest tests/ --cov=idx_api --cov-report=term-missingView Coverage in Terminal
Section titled “View Coverage in Terminal”For quick checks without opening HTML reports:
# Show missing lines in terminaluv run pytest tests/ --cov=idx_api --cov-report=term-missing
# Just show the summaryuv run pytest tests/ --cov=idx_api --cov-report=termExclude Code from Coverage
Section titled “Exclude Code from Coverage”Some code should be intentionally excluded from coverage:
# pragma: no cover - for code that shouldn't be testedif __name__ == "__main__": # pragma: no cover run()Configure global exclusions in pyproject.toml:
[tool.coverage.run]omit = [ "*/tests/*", "*/__pycache__/*",]Publish Coverage to Docs
Section titled “Publish Coverage to Docs”After generating coverage reports, publish them to the documentation site:
# Generate and publish in one stepmake test-publish
# Or separatelymake test-coveragemake publish-docsThe coverage report will be available at: /reports/coverage/index.html