"""Test bootstrap for the ResearchBee Release A regression suite.""" from __future__ import annotations import sys import types from pathlib import Path ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) # The production image installs tenacity from requirements.txt. The execution # environment used for static/offline review may not have it, so provide a tiny # decorator-compatible fallback only when the real package is unavailable. try: # pragma: no cover - exercised only in minimal review environments import tenacity # noqa: F401 except ModuleNotFoundError: # pragma: no cover module = types.ModuleType("tenacity") def retry(*_args, **_kwargs): def decorator(func): return func return decorator def option(*_args, **_kwargs): return object() module.retry = retry module.stop_after_attempt = option module.wait_exponential = option module.retry_if_exception_type = option module.before_sleep_log = option sys.modules["tenacity"] = module # Same offline-review fallback for the OpenAI SDK. Production installs the real # package from requirements.txt; these tests never make a model call. try: # pragma: no cover from openai import AsyncOpenAI # noqa: F401 except ModuleNotFoundError: # pragma: no cover module = types.ModuleType("openai") class OpenAIError(Exception): pass class RateLimitError(OpenAIError): pass class APIStatusError(OpenAIError): def __init__(self, *args, status_code=500, **kwargs): super().__init__(*args) self.status_code = status_code class AsyncOpenAI: def __init__(self, *args, **kwargs): self.chat = types.SimpleNamespace() module.AsyncOpenAI = AsyncOpenAI module.RateLimitError = RateLimitError module.APIStatusError = APIStatusError sys.modules["openai"] = module