Add regression coverage for automation review-thread fixes#6
Conversation
PR Summary by QodoAdd regression tests for automation review-thread fixes
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Docstring test brittleness
|
| def test_quick_start_uses_package_imports(): | ||
| assert isinstance(automation_doc, str) | ||
| assert automation_doc.strip() | ||
| assert "from automation import AutomationEngine" in automation_doc | ||
| assert "from src.automation import" not in automation_doc |
There was a problem hiding this comment.
1. Docstring test brittleness 🐞 Bug ☼ Reliability
test_quick_start_uses_package_imports hard-requires automation.__doc__ to be a non-empty str and to contain specific text, so it can fail in environments where docstrings are stripped or if the quick-start formatting changes without changing the intended import contract. This makes the regression coverage less reliable than necessary.
Agent Prompt
### Issue description
`test_quick_start_uses_package_imports` asserts against `automation.__doc__` directly. This couples the test to runtime docstring availability and exact formatting, making it easy to fail in certain execution modes or after harmless docstring edits.
### Issue Context
The quick-start content is defined in the module docstring of `src/automation/__init__.py`. The regression goal is to ensure the *example imports* reference `automation` (package import) rather than `src.automation`.
### Fix Focus Areas
- tests/test_automation_review_regressions.py[1-4]
- tests/test_automation_review_regressions.py[79-83]
### Suggested fix
Update the test to assert against the module *source text* instead of `__doc__`, e.g.:
- `import automation, pathlib`
- `text = pathlib.Path(automation.__file__).read_text(encoding="utf-8")`
- Assert the expected quick-start import lines are present/absent within `text`.
(Alternative: if you intentionally want to validate the runtime docstring, add a guard like `if automation_doc is None: pytest.skip(...)`.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Pull request overview
Adds a focused regression test suite for the automation package to lock in behaviors discussed in review thread 4595682762, covering generator-variable drain semantics, component lifecycle behavior, engine failure behavior for missing variables, and the package quick-start import example.
Changes:
- Adds regression coverage for
GeneratorVariable.peek()+collect()to ensure a peeked value is not lost when draining. - Adds regression coverage for component registry replacement teardown and for
FunctionComponentreturning traceback text on callable failure. - Adds regression coverage that missing declared variables fail an automation run, and that the
automationpackage docstring quick-start usesfrom automation import …imports.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_collect_includes_peeked_value(): | ||
| variable = GeneratorVariable.from_iterable([1, 2, 3]) | ||
|
|
||
| assert variable.peek() == 1 | ||
| assert variable.collect() == [1, 2, 3] |
This PR captures the behaviors called out in review thread
4595682762with focused regression tests, so the reviewed fixes remain enforced across the automation package. The coverage targets the generator variable, component registry, engine failure path, and package quick-start import example.Generator variable drain semantics
peek()+collect()interaction to ensure a peeked value is preserved when draining the remaining sequence.Component lifecycle and failure reporting
FunctionComponentsurfaces traceback text when wrapped callables fail.Automation engine variable handling
Package quick-start contract
automationimports rather than a non-packagesrc.automationpath.