From 93c266ae51e1a7e928ac7092767e5a9f4691d002 Mon Sep 17 00:00:00 2001 From: Diya Maheshwari Date: Tue, 14 Jul 2026 16:03:12 +0530 Subject: [PATCH] fix(tests): guard OpenAI embedding tests and drop read-only property monkeypatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extend skipif guard on TestOpenAIBatchSplitting to require both pydantic-ai and openai, since _build_model imports pydantic_ai.embeddings.openai which needs the openai package. - Remove monkeypatch.setattr on llm_model_name in the classification stub-fallback fixture — it's a read-only derived property that already resolves to None once llm_provider/llm_model are patched. Fixes #288 --- .../classification/test_classification_stub_fallback.py | 1 - .../embedding/test_pydantic_ai_embedding_adapter.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/integration/classification/test_classification_stub_fallback.py b/tests/integration/classification/test_classification_stub_fallback.py index 4d9eeb40..59be2d9a 100644 --- a/tests/integration/classification/test_classification_stub_fallback.py +++ b/tests/integration/classification/test_classification_stub_fallback.py @@ -26,7 +26,6 @@ def llm_disabled(self, monkeypatch: pytest.MonkeyPatch) -> None: """Force the LLM selector into its ``disabled`` branch.""" monkeypatch.setattr(settings, "llm_provider", None) monkeypatch.setattr(settings, "llm_model", None) - monkeypatch.setattr(settings, "llm_model_name", None) @pytest.mark.asyncio async def test_stub_classifier_produces_dto(self): diff --git a/tests/unit/_core/infrastructure/embedding/test_pydantic_ai_embedding_adapter.py b/tests/unit/_core/infrastructure/embedding/test_pydantic_ai_embedding_adapter.py index 618fc118..33892cfc 100644 --- a/tests/unit/_core/infrastructure/embedding/test_pydantic_ai_embedding_adapter.py +++ b/tests/unit/_core/infrastructure/embedding/test_pydantic_ai_embedding_adapter.py @@ -6,6 +6,10 @@ from src._core.domain.value_objects.embedding_config import EmbeddingConfig _has_pydantic_ai = importlib.util.find_spec("pydantic_ai") is not None +_has_openai_embeddings = ( + importlib.util.find_spec("pydantic_ai") is not None + and importlib.util.find_spec("openai") is not None +) class TestEmbeddingConfigValueObject: @@ -156,7 +160,9 @@ async def test_error_mapping_generic(self): await adapter.embed_text("test") -@pytest.mark.skipif(not _has_pydantic_ai, reason="pydantic-ai not installed") +@pytest.mark.skipif( + not _has_openai_embeddings, reason="pydantic-ai + openai not installed" +) class TestOpenAIBatchSplitting: """OpenAI 프로바이더의 배치 분할 로직 테스트."""