Extend unit tests#44
Conversation
Reviewer's GuideRefactors Hatch test environment configuration to use a single default env with reusable scripts, introduces a matrix-based test env for CI, tightens coverage settings, and simplifies the GitHub Actions workflow to run tests with coverage via the new Hatch commands while removing the old tests directory. Flow diagram for Hatch-driven test and coverage executionflowchart LR
A["Start"] --> B["Developer or CI runs 'hatch run test-cov' in default environment"]
B --> C["Hatch loads 'default' environment with testing and linting dependencies"]
C --> D["Execute pytest with coverage options\n--cov=ibutsu_client\n--cov-report=xml, term-missing, html"]
D --> E["coverage.run applies configuration\n- source: 'ibutsu_client'\n- branch coverage: true\n- omit patterns: '*/test/*', '*/tests/*', '*/test_*', '*/conftest.py', '*/__pycache__/*', '*/site-packages/*'"]
E --> F["coverage.report applies rules\n- precision: 2\n- skip_empty: true\n- exclude_lines: pragmas, TYPE_CHECKING, abstract methods, debug-only, overloads"]
F --> G["Generate coverage outputs\n- XML report\n- Terminal report (term-missing)\n- HTML report in 'htmlcov'"]
G --> H["CI or developer reviews coverage results"]
H --> I["End"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The new coverage
exclude_linespatterns (e.g.,if.*__debug__:and the broad Protocol/overload regexes) look quite generic and may inadvertently mask real code from coverage; consider tightening these regexes to only match the specific constructs you need to ignore. - By adding
pre-committo the default Hatch environment, every default env creation will pull in linting tooling; if you want to keep the default env lean for general development, consider moving linting tools into a separatelintordevenvironment and wiring thelintscript to that.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new coverage `exclude_lines` patterns (e.g., `if.*__debug__:` and the broad Protocol/overload regexes) look quite generic and may inadvertently mask real code from coverage; consider tightening these regexes to only match the specific constructs you need to ignore.
- By adding `pre-commit` to the default Hatch environment, every default env creation will pull in linting tooling; if you want to keep the default env lean for general development, consider moving linting tools into a separate `lint` or `dev` environment and wiring the `lint` script to that.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
There was a problem hiding this comment.
Pull request overview
This PR modernizes the test infrastructure by restructuring the Hatch environment configuration and streamlining the CI workflow. The changes simplify local development and CI execution while maintaining comprehensive test coverage across multiple Python versions.
Key changes:
- Replaced the standard
hatch-testenvironment with a customdefaultenvironment that includes explicit test dependencies and convenient scripts - Enhanced coverage configuration with better documentation and more comprehensive exclusion patterns
- Simplified the GitHub Actions workflow by consolidating test execution into a single command
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests | Removed unused file containing only "test" |
| pyproject.toml | Restructured Hatch environments from hatch-test to default with custom scripts, added explicit test dependencies, and improved coverage configuration with clearer comments and additional exclusion patterns |
| .github/workflows/tests.yml | Simplified workflow by replacing multi-step test execution with single hatch run test-cov command that handles pytest, coverage generation, and reporting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary by Sourcery
Update test environment configuration and coverage settings to streamline local and CI testing.
Enhancements:
CI:
Tests: