Skip to content

Extend unit tests#44

Merged
mshriver merged 3 commits into
mainfrom
extend-unit-tests
Nov 21, 2025
Merged

Extend unit tests#44
mshriver merged 3 commits into
mainfrom
extend-unit-tests

Conversation

@mshriver
Copy link
Copy Markdown
Contributor

@mshriver mshriver commented Nov 21, 2025

Summary by Sourcery

Update test environment configuration and coverage settings to streamline local and CI testing.

Enhancements:

  • Consolidate Hatch test environments into a default environment with predefined test, coverage, and lint scripts.
  • Refine coverage configuration to better exclude non-runtime code and standard debugging or type-checking patterns, and to handle empty files more cleanly.

CI:

  • Simplify the CI test workflow to use the new Hatch test-cov script for running tests with coverage.

Tests:

  • Remove the legacy tests package in favor of the updated testing and coverage setup.

Copilot AI review requested due to automatic review settings November 21, 2025 16:35
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Nov 21, 2025

Reviewer's Guide

Refactors 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 execution

flowchart 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"]
Loading

File-Level Changes

Change Details Files
Consolidated and modernized Hatch environments and test tooling configuration.
  • Replaced separate hatch-test and test environments with a unified default environment that includes pytest, coverage, xdist, rerunfailures, pytest-mock, and pre-commit as dependencies.
  • Defined reusable Hatch scripts for running tests, coverage-enabled tests, generating coverage reports (text, XML, HTML), and running lint via pre-commit.
  • Created a test-matrix Hatch environment that inherits from the default template and defines a Python version matrix for 3.11–3.13.
pyproject.toml
Tightened and clarified coverage configuration for both run and report phases.
  • Updated coverage run configuration to also omit files under any tests directory in addition to test, test_* modules, conftest, and caches.
  • Enhanced coverage report configuration by setting precision and skip_empty explicitly and expanding exclude_lines to cover docstrings, defensive programming patterns, type-checking-only blocks, abstract methods, main guards, and protocol/overload definitions.
  • Removed redundant or less-structured coverage report options in favor of a more explicit, categorized exclude list.
pyproject.toml
Simplified CI workflow to rely on the new Hatch test scripts for running tests with coverage and producing XML reports.
  • Stopped creating a dedicated Hatch env in CI and instead run tests directly through Hatch using the project configuration.
  • Replaced the previous hatch test and explicit coverage XML generation commands with a single hatch run test-cov invocation that runs tests with coverage reporting.
  • Kept Codecov upload step but now relies on the coverage artifacts produced by the new test-cov script.
.github/workflows/tests.yml
Removed the legacy tests directory from the repository.
  • Deleted the existing tests directory, presumably in preparation for or replacement by a new test layout or updated unit tests elsewhere.
tests

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 21, 2025

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 ☂️

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-test environment with a custom default environment 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.

@mshriver mshriver merged commit f49d478 into main Nov 21, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants