diff --git a/libs/mongodb/tests/integration_tests/test_parent_document.py b/libs/mongodb/tests/integration_tests/test_parent_document.py index 444c06d..afd01d2 100644 --- a/libs/mongodb/tests/integration_tests/test_parent_document.py +++ b/libs/mongodb/tests/integration_tests/test_parent_document.py @@ -32,13 +32,12 @@ def embedding_model() -> Embeddings: from langchain_openai import OpenAIEmbeddings - try: - return OpenAIEmbeddings( - openai_api_key=os.environ["OPENAI_API_KEY"], # type: ignore # noqa - model="text-embedding-3-small", - ) - except Exception: + if not os.environ.get("OPENAI_API_KEY"): return ConsistentFakeEmbeddings(DIMENSIONS) + return OpenAIEmbeddings( + openai_api_key=os.environ["OPENAI_API_KEY"], # type: ignore # noqa + model="text-embedding-3-small", + ) def test_1clxn_retriever( diff --git a/libs/mongodb/tests/integration_tests/test_retrievers.py b/libs/mongodb/tests/integration_tests/test_retrievers.py index 6406b01..fa3b79c 100644 --- a/libs/mongodb/tests/integration_tests/test_retrievers.py +++ b/libs/mongodb/tests/integration_tests/test_retrievers.py @@ -47,8 +47,8 @@ def example_documents() -> List[Document]: def embedding_openai() -> Embeddings: from langchain_openai import OpenAIEmbeddings - if os.environ.get("OPENAI_API_KEY") is None: - pytest.skip("test_retrievers expects OPENAI_API_KEY in os.environ") + if not os.environ.get("OPENAI_API_KEY"): + pytest.skip("test_retrievers expects OPENAI_API_KEY in os.environ") from langchain_openai import OpenAIEmbeddings