Skip to content

Expand test suite#19

Merged
g-eoj merged 8 commits intomainfrom
add-test-suite
Feb 17, 2026
Merged

Expand test suite#19
g-eoj merged 8 commits intomainfrom
add-test-suite

Conversation

@g-eoj
Copy link
Copy Markdown
Owner

@g-eoj g-eoj commented Feb 17, 2026

Summary

  • Add 58 tests across three focused modules with 98% coverage
  • Fix several CI issues that were silently failing
  • Align local pre-commit with CI so they catch the same problems
  • Clean up dev dependencies now that the example code has moved

Tests

Replaces the original 4-test test_.py with three focused modules:

  • test_grammar.pybuild_grammar and make_guided_extra_body: all element types, edge cases (regex escaping, UID ordering, custom tokens, tool_names vs regex)
  • test_json_schema.pybuild_json_schema: all branches including ObjectOutputProcessor, DeferredToolRequests, BinaryImage, deduplication, and $defs merging from shared sub-models
  • test_agent.pyCRAgent.set_guide: error handling, model settings preservation, idempotent re-configuration, toolset schema merging, and the original end-to-end output type snapshot tests
Module Coverage
cragents/__init__.py 100%
cragents/_types.py 100%
cragents/_utils.py 94%
cragents/_version.py 100%
Total 98%

CI fixes

  • make test is now used in the workflow so Makefile and CI can't drift apart
  • coverage combine and coverage report steps were missing — coverage data was being collected by parallel workers but never merged or reported
  • Test job now runs a matrix of pydantic-ai min (--resolution lowest-direct) and pydantic-ai latest (--upgrade-package) in parallel
  • Remove --all-extras from uv sync calls since the project has no optional dependencies

Pre-commit / local dev

  • Remove the format hook from .pre-commit-config.yaml — it was auto-fixing issues before lint ran, silently masking errors that CI would catch
  • Add make install target to set up git hooks (uv run pre-commit install)

Dependencies

  • Remove example dependency group (moved to separate repo), reducing the lockfile by ~1,450 lines
  • Add pre-commit explicitly to the dev group (was previously only a transitive dep through the example group)
  • Tighten dev dependency lower bounds to match currently locked versions

Test plan

  • All 58 tests pass locally
  • make lint and make typecheck clean
  • CI matrix (pydantic-ai min + latest) passing on GitHub

🤖 Generated with Claude Code

g-eoj and others added 8 commits February 17, 2026 10:52
Replace the single test_.py with three focused modules:
- test_grammar.py: build_grammar and make_guided_extra_body (22 tests)
- test_json_schema.py: build_json_schema covering all branches (9 tests)
- test_agent.py: CRAgent.set_guide, vllm_model_profile, and original
  end-to-end output type tests (27 tests)

Increases total coverage from ~4 tests to 58 tests, with 98% overall
coverage and 100% branch coverage of cragents/__init__.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pytest-xdist writes per-worker coverage files that must be merged
with `coverage combine` before `coverage report` can read them.
Without this, CI collected no coverage data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Runs pre-commit install so that hooks in .pre-commit-config.yaml
are triggered automatically on every git commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the format hook from pre-commit so both local and CI
environments run ruff in check-only mode (make lint). Auto-fixing
was silently masking lint errors before commit.

Also fix the unsorted import in test_grammar.py that exposed the gap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a matrix to the test job that runs twice in parallel:
- min: installs exactly pydantic-ai==1.25.1 (the declared minimum)
- latest: upgrades pydantic-ai to the newest published version

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
--override is not a valid uv flag. --resolution lowest-direct is the
correct uv mechanism: it resolves direct dependencies to their lowest
allowed version as declared in pyproject.toml, so the min version is
always read from source rather than hardcoded in the workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pre-commit was only a transitive dep through the example group so
add it explicitly to the dev group. Also drop --all-extras from CI
uv sync calls since the project has no optional-dependencies defined.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@g-eoj g-eoj marked this pull request as ready for review February 17, 2026 20:08
@g-eoj g-eoj added the ai AI was used to generate part of this code. label Feb 17, 2026
@g-eoj g-eoj changed the title Expand test suite and split into focused test files Expand test suite Feb 17, 2026
@g-eoj g-eoj merged commit dc83ff6 into main Feb 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai AI was used to generate part of this code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant