fix(tests): make dtu tool-composition test portable and collection-safe#30
Merged
Conversation
tests/dtu/test_tool_delegate_composition.py hardcoded an absolute, root-owned path /root/.amplifier/cache/amplifier-bundle-context-intelligence-ecd41f3e6fa67bd2 and executed its validation logic (including sys.exit(1)) at MODULE/import level. On any machine that isn't that exact DTU container, this raised PermissionError during pytest collection and aborted the ENTIRE tests/ collection. Fix: resolve the bundle root relative to the test file (Path(__file__).resolve().parents[2]) — the agent/mode files under test are shipped in this repo — and move the logic into a proper def test_tool_delegate_composition() function that asserts instead of sys.exit. Kept an if __name__ == "__main__" runner so it still works as a standalone DTU script. No behavioral change to the 14 checks.
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.
Problem
tests/dtu/test_tool_delegate_composition.pyhardcoded an absolute, root-owned cache path and ran its checks at import time:On any environment other than that exact DTU container this raised
PermissionError: [Errno 13] Permission denied: '/root/.amplifier/cache/...'during pytest collection, which aborted collection for the wholetests/tree (1 error, 0 tests run from the top-level suite).Fix
BUNDLE_ROOT = Path(__file__).resolve().parents[2]. The agent and mode files under test (agents/context-intelligence-design-facilitator.md,agents/context-intelligence-tool-designer.md,modes/context-intelligence.md) ship in this repo, so the repo root is the correct, portable source — works in a checkout, in CI, and inside a DTU alike.def test_tool_delegate_composition()thatasserts on failures instead ofsys.exit(1), so collection no longer executes the body. Retained anif __name__ == "__main__"runner so the file still works as a standalone DTU script. All 14 Group-D checks are unchanged.Test Plan
tests/dtu/test_tool_delegate_composition.py: 1 passed (was a collection error)