-
Notifications
You must be signed in to change notification settings - Fork 7
Fix tests in scripts/ for Python 3.12 by correcting mock assertion usage
#293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe test files for backend and test pre-start initialization were refactored to consolidate their logic. Each now contains a single, simplified test that mocks session and select behavior, removes logger patching, and focuses on verifying successful execution of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Graph Analysis (1)backend/app/tests/scripts/test_test_pre_start.py (1)
🔇 Additional comments (10)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
This PR fixes a compatibility issue with Python 3.12 that caused all tests in the
scripts/directory to fail due to incorrect usage ofcalled_once_withon a mock object.Target issue is #228
In Python 3.11 and earlier, using
called_once_withas an attribute on a mock did not raise an error. However, Python 3.12 enforces stricter checks, and usingcalled_once_withdirectly now results in:called_once_withusage with the correctassert_called_once_with(...)assertion.Sessioncontext manager andselectcall inside theinit()function.Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Summary by CodeRabbit