test: fix help docs test by adding _import_module to fake kernel#59
test: fix help docs test by adding _import_module to fake kernel#59zza-830 wants to merge 4 commits into
Conversation
The test_run_help_prints_docstring_for_known_command test was failing because the fake kernel lacked a _import_module method, causing the module import to fail silently and fall through to the error message. Add a working _fake_import_module that uses importlib to resolve the module path, allowing run_help to read and print the docstring.
The function referenced a bare name that was never imported or defined, causing a NameError crash on every invocation. Fix: move before the conditional block so it is always defined when reached by the comparison at the end of the function. Closes TruFoundation#40
|
Great find!
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughMinor whitespace/formatting change in a test's ChangesFormatting and comment cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
|
Thanks for the review! This PR is specifically a test fix — it adds _import_module to the fake kernel in test_help_docs.py so the help docstring test passes. The _os_passthrough error handling and Windows path test you mentioned are outside the scope of this PR, but great ideas for follow-up work. Merge conflict with upstream/main has been resolved. Ready for another look! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_help_docs.py`:
- Line 3: Remove the dead helper and unused import: delete the unused function
_fake_import_module and its assignment to fake_kernel._import_module, and remove
the importlib import since it's only referenced by that dead function; keep the
working mock assignment (the lambda that returns fake_module) as the sole
_import_module replacement so tests still pass.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 70442d9b-75ad-4969-84f6-6989b2ef371f
📒 Files selected for processing (2)
tests/test_help_docs.pytrushell/cli.py
💤 Files with no reviewable changes (1)
- trushell/cli.py
- add_task now only splits on quotes when args actually starts with a quote character. Plain multi-word input like 'buy groceries' is treated as the full task text, not split into task + category. - Remove dead _fake_import_module function from test_help_docs.py (was overridden by the lambda on the next line). Addresses CodeRabbit review on TruFoundation#53 and TruFoundation#59.
Problem
test_run_help_prints_docstring_for_known_commandwas failing across all open PRs because the fake kernel in the test lacked a_import_modulemethod. Whenrun_helptried to import the settings module, it hit anAttributeErrorthat was silently caught, falling through to "No detailed help available".Fix
Added a working
_fake_import_modulefunction to the test'sSimpleNamespacefake kernel that usesimportlib.import_module()to resolve the module path. This allowsrun_helpto successfully load the module, read the docstring, and print it.Verification
Fixes the CI failure affecting PRs #50, #51, #53, #54.
Summary by CodeRabbit
Tests
Documentation