diff --git a/tests/conftest.py b/tests/conftest.py index bac107ea..ab0a393e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,6 +22,29 @@ if project_root not in sys.path: from defer.sugar import install install() +# Per the user spec (startup_speedup_20260606 spec.md:2.2 Layer 3, +# and the message in workflow.md about warmup notifications): the +# AppController's warmup mechanism loads heavy modules on the _io_pool +# background thread at startup. Tests that touch these modules must +# wait for warmup to complete; otherwise they race against a partial +# google.genai import and hit "partially initialized" errors. +# +# Wait for the warmup before any test runs. The AppController is +# created in a session-scoped fixture; if it already exists (e.g., +# the live_gui fixture also creates one), this call is a no-op or +# fast (warmup already done). +from src.app_controller import AppController +_warmup_app_controller = AppController() +if not _warmup_app_controller.wait_for_warmup(timeout=60.0): + import warnings + warnings.warn( + "AppController warmup did not complete within 60s. " + "Tests that depend on warmup modules (google.genai, anthropic, " + "openai, etc.) may fail.", + RuntimeWarning, + stacklevel=2, + ) + from src.gui_2 import App class VerificationLogger: