fix(tests): make test_tool_v0 mock import-order independent#1269
Conversation
## Summary `test_tool_v0.py` only installed its `post_with_retry` stub when `ai.common.utils` wasn't already imported. When a prior test on the same pytest worker imported the real module first, `tool_v0` kept the real `post_with_retry` and made live `api.v0.dev` calls → `401`, failing 7 `TestGenerateUi` tests under the full suite (passes in isolation). Rebind `post_with_retry` and `normalize_tool_input` on the loaded module after import — same pattern the test already uses for `warning` — so the stubbing is robust regardless of import order. ## Testing - Repro (`test_config_utils.py` then `test_tool_v0.py`): 7 failed → all pass. - `test_tool_v0` in isolation: still passes. - Full `./builder test`: green. Closes #1268
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe test module strengthens its import stubbing by rebinding three functions— ChangesTest mock rebinding for import-order resilience
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Internal: Discord sync markerAuto-managed by the Discord notification workflow. Stores the linked Discord message ID. Do not edit or delete. |
Summary
test_tool_v0.pyonly installed itspost_with_retrystub whenai.common.utilswasn't already imported. When a prior test on the same pytest worker imported the real module first,tool_v0kept the realpost_with_retryand made liveapi.v0.devcalls →401, failing 7TestGenerateUitests under the full suite (passes in isolation).Rebind
post_with_retryandnormalize_tool_inputon the loaded module after import — same pattern the test already uses forwarning— so the stubbing is robust regardless of import order.Testing
test_config_utils.pythentest_tool_v0.py): 7 failed → all pass.test_tool_v0in isolation: still passes../builder test: green.Closes #1268
Summary by CodeRabbit