test(pyamber): add unit tests for update_executor logic#4719
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4719 +/- ##
============================================
- Coverage 42.95% 42.49% -0.46%
+ Complexity 2035 2032 -3
============================================
Files 957 957
Lines 34077 34094 +17
Branches 3753 3753
============================================
- Hits 14637 14488 -149
- Misses 18663 18832 +169
+ Partials 777 774 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds pytest coverage for PyAmber executor hot-swap behavior by testing ExecutorManager.update_executor directly and the UpdateExecutorHandler wrapper to ensure correct delegation and state preservation semantics.
Changes:
- Extend
test_executor_manager.pywith a newTestUpdateExecutorsuite covering state preservation, version/module increments, and error paths. - Add
test_update_executor_handler.pyto validate handler delegation, return type, and oneof extraction behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| amber/src/main/python/core/architecture/managers/test_executor_manager.py | Adds unit tests for ExecutorManager.update_executor, including state carryover and assertion/error cases. |
| amber/src/main/python/core/architecture/handlers/control/test_update_executor_handler.py | Adds unit tests ensuring UpdateExecutorHandler.update_executor delegates correctly and extracts code via get_one_of. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes apache#4718 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1cb6443 to
9926f45
Compare
Replace `__dict__.get(key) == value` with an explicit `key in __dict__` membership check before the value comparison so a key that disappeared from the executor with an expected value of `None` no longer slips past on `get()`'s default return.
What changes were proposed in this PR?
Adds pytest coverage for
ExecutorManager.update_executor(extending the existingtest_executor_manager.py) and theUpdateExecutorHandlerthat wraps it (newtest_update_executor_handler.py).Any related issues, documentation, discussions?
Closes #4718.
Test-isolation note (not pinned by these tests): the existing
executor_managerfixture has a buggy cleanup guard —if hasattr(manager, "_fs"): manager.close()checks for_fsbut thecached_propertyactually stores underfs, soclose()is never invoked. Combined with the fact that every freshExecutorManagerresetsexecutor_versionto 0 and thus reuses the module nameudf-v1, this leaves stale modules insys.moduleswith paths that point at deleted tmp dirs from earlier tests. The newTestUpdateExecutortherefore avoids asserting on the class of the loaded executor and instead checks dict-state preservation via setattr/getattr, so it works regardless of which cachedudf-v1happens to satisfy the import. A separate fix would untangle the cleanup guard and probably move version numbering off of the per-manager counter.How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-7)