test: expand test coverage with edge cases, error paths, and shared conftest#61
Merged
test: expand test coverage with edge cases, error paths, and shared conftest#61
Conversation
Move duplicated Pydantic schemas (NumberInput, ValueOutput, ValueInput, FormattedOutput), helper functions (_double_fn, _add_ten_fn, _format_fn), and pytest fixtures (double_tool, add_ten_tool, format_tool, linear_flow, executor) from test_flow_execution.py into tests/conftest.py. Remove tests/__init__.py so pytest auto-adds the test directory to sys.path, enabling direct imports from conftest. Part of #6.
Remove the empty tests/__init__.py so that pytest adds the test directory to sys.path, allowing test modules to import from conftest.py directly.
…tion - Replace inline schemas/fixtures with imports from conftest.py. - Add TestSingleStepFlow: one-step flow with input_mapping. - Add TestContextAccumulation: verify all step outputs in final_output. - Add TestToolZeroDivisionError: ZeroDivisionError wrapped as FlowExecutionError. - Add TestBoundaryValues: negative numbers, zero, and large negatives. Closes #6 (test_flow_execution.py portion).
- Add test_empty_registry_returns_none to TestMatchFlowByIntent. - Add TestOverwritePreservesCount: verify len() stays the same after overwrite. Closes #6 (test_registry.py portion).
Add pytest-cov>=4.0 to [project.optional-dependencies] dev for coverage reporting during local development.
There was a problem hiding this comment.
Pull request overview
This PR expands test coverage for the chainweaver package by adding new test cases for edge cases and error paths, and refactors shared test infrastructure into a central conftest.py.
Changes:
- New test cases in
test_flow_execution.pyfor single-step flows, context accumulation,ZeroDivisionErrorwrapping, and boundary values (negative numbers, zero, large negatives) - New test cases in
test_registry.pyfor empty-registry intent matching and overwrite-preserves-count behavior - Shared Pydantic schemas, helper functions, and pytest fixtures extracted from
test_flow_execution.pyinto a newtests/conftest.py;tests/__init__.pyremoved;pytest-cov>=4.0added to dev dependencies
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/test_flow_execution.py |
Removes in-file fixtures/schemas (moved to conftest); adds TestSingleStepFlow, TestContextAccumulation, TestToolZeroDivisionError, and TestBoundaryValues |
tests/test_registry.py |
Adds test_empty_registry_returns_none to TestMatchFlowByIntent and a new TestOverwritePreservesCount class |
tests/conftest.py |
New file with shared Pydantic schemas, tool functions, and pytest fixtures for all test files |
tests/__init__.py |
Removed to enable rootdir-based pytest discovery (allows from conftest import in test files) |
pyproject.toml |
Adds pytest-cov>=4.0 to dev optional dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Closes #6 — expand test coverage for edge cases, error paths, and context accumulation.
New test cases in
tests/test_flow_execution.pyTestSingleStepFlow— one-step flow withinput_mapping(simplest chaining case)TestContextAccumulation— verifies that outputs from all steps (not just the last) are merged intofinal_output, including the originalinitial_inputkeysTestToolZeroDivisionError—ZeroDivisionErrorinside a tool fn is wrapped asFlowExecutionErrorTestBoundaryValues— negative numbers, zero, and large negatives through the double→add→format chainNew test cases in
tests/test_registry.pytest_empty_registry_returns_none—match_flow_by_intenton an empty registry returnsNoneTestOverwritePreservesCount—len()stays the same afterregister_flow(..., overwrite=True)Structural improvements
tests/conftest.py(new) — shared Pydantic schemas (NumberInput,ValueOutput,ValueInput,FormattedOutput), helper functions (_double_fn,_add_ten_fn,_format_fn), and pytest fixtures (double_tool,add_ten_tool,format_tool,linear_flow,executor) extracted fromtest_flow_execution.pytests/__init__.pyremoved — allows pytest to auto-add the test directory tosys.pathso test modules can import fromconftest.pypyproject.toml— addedpytest-cov>=4.0to[project.optional-dependencies] devNote on issue scope
The issue listed
test_empty_flow_succeeds— this test already existed inTestEmptyFlowso no duplicate was added.Why
Missing coverage for edge cases (single-step, boundary values, context accumulation) and specific exception types (
ZeroDivisionError) reduced confidence for the v0.1.0 release. Shared fixtures reduce duplication across test files.How verified
Coverage: 99% (213 statements, 3 missed)
__init__.pyexceptions.pyexecutor.pyflow.pylog_utils.pyregistry.pytools.pyTradeoffs / risks
tests/__init__.pychanges how pytest discovers tests (rootdir-based instead of package-based). This is the standard pytest recommendation and has no practical impact for this project.