test(conviction): stop reloaded conviction_flow env overrides leaking across tests - #1499
Conversation
…verride tests The deployment cron/timezone are read from the environment at import time, so reloading etl.conviction_flow under patched env left the overridden schedule on the shared module object for the rest of the session. Running tests/test_crowded_contrarian.py before tests/test_conviction_flow.py made test_conviction_deployment_nightly_utc_schedule fail with assert '15 3 * * *' == '0 2 * * *'.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 40 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Comment |
Provider Comparison ReportProvider Summary
📋 Full Provider Details (click to expand)openai
anthropic
Agreement
DisagreementNo major disagreements detected. Unique Insights
🔍 LangSmith Traces |
|
Workflow state fingerprint for Agents Verifier. Do not edit. |
Problem
tests/test_crowded_contrarian.pyreloadsetl.conviction_flowwhileCONVICTION_FLOW_CRON/CONVICTION_FLOW_TIMEZONEare monkeypatched, and never restores the module. Because the module resolves its deployment schedule from the environment at import time:the overridden schedule stays on the shared module object for the rest of the pytest session. Any later test that reads the module-level deployment then sees
15 3 * * */America/New_York.Reproduced on current
main(872569b):CI has been green only by accident of collection order: pytest collects files alphabetically, so
test_conviction_flow.pyruns beforetest_crowded_contrarian.py. Any reordering, sharding,-p randomly, or-k/path selection that puts the crowding tests first turns this into a confusing red that looks like a scheduling bug rather than test pollution.Fix
A
reload_conviction_modulefixture owns the reload and restores the pristine module on teardown by dropping the env overrides and reloading again. Both deployment tests now go through it. The teardown deliberately does not forceTZ, so the restored timezone matches whatever the module saw at original import.A new regression test,
test_conviction_module_schedule_restored_after_env_override_reload, runs right after the override test and asserts the shared module is back to the nightly default — this is the gate that fails if the restore is ever dropped again.Test gate
pytest -o addopts= tests/test_crowded_contrarian.py tests/test_manager_similarity_flow.py tests/test_conviction_flow.py tests/test_alert_engine.py= 38 passed (was 1 failed / 36 passed onmain).pytest -o addopts= tests/test_crowded_contrarian.py tests/test_conviction_flow.py::test_conviction_deployment_nightly_utc_schedule= 16 passed.pytest -o addopts= tests/test_alert_engine.py tests/test_conviction_flow.py tests/test_crowded_contrarian.py tests/test_manager_similarity_flow.py= 38 passed.importlib.reloadremoved, the narrow repro fails on both the new gate and the original victim test —FAILED tests/test_crowded_contrarian.py::test_conviction_module_schedule_restored_after_env_override_reloadandFAILED tests/test_conviction_flow.py::test_conviction_deployment_nightly_utc_schedule(2 failed, 14 passed). The break was reverted and the suite re-run green.ruff checkclean;black --checkclean;git diff --checkclean.Scope
Tests only — one file, +32/-4. No production module, migration, or schema change. Found by the closer lane while validating the rebase of #1498 onto
mainafter #1497 merged; kept out of that PR because it is unrelated to the short-interest feature.