mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
test_retry_logic.py injected sys.modules["openai"] = MagicMock() at module level so providers.py could be imported without the real openai package. Those mocks were never restored, leaving openai (and spacy, instructor etc.) as MagicMock objects for the entire test session. This caused test_pr482_deepseek_openai tests to receive a MagicMock when importing openai.OpenAI, making MagicMock(spec=OpenAI) raise InvalidSpecError. Fix: save original sys.modules entries before injection and restore them immediately after the semantica imports that needed the mocks complete. The mock objects remain bound inside the already-imported provider module, so test_retry_logic tests are unaffected; other test modules now see the real packages again. Co-authored-by: Zohaib Hassan <zohaib179949@gmail.com> Co-authored-by: KaifAhmad1 <kaifahmad087@gmail.com>