diff --git a/tests/conftest.py b/tests/conftest.py index 093eada5c..5babac6e1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1125,6 +1125,16 @@ def langchain_community_fixture(fail_missing: bool): fail_missing=fail_missing) +@pytest.fixture(name="langchain_openai", scope='session') +def langchain_community_fixture(fail_missing: bool): + """ + Fixture to ensure langchain_openai is installed + """ + yield import_or_skip("langchain_openai", + reason=OPT_DEP_SKIP_REASON.format(package="langchain_openai"), + fail_missing=fail_missing) + + @pytest.fixture(name="langchain_nvidia_ai_endpoints", scope='session') def langchain_nvidia_ai_endpoints_fixture(fail_missing: bool): """ diff --git a/tests/morpheus_llm/llm/conftest.py b/tests/morpheus_llm/llm/conftest.py index 427b8b46c..8d196720a 100644 --- a/tests/morpheus_llm/llm/conftest.py +++ b/tests/morpheus_llm/llm/conftest.py @@ -61,6 +61,14 @@ def langchain_community_fixture(langchain_community: types.ModuleType): yield langchain_community +@pytest.fixture(name="langchain_openai", scope='session', autouse=True) +def langchain_community_fixture(langchain_openai: types.ModuleType): + """ + Fixture to ensure langchain_openai is installed + """ + yield langchain_openai + + @pytest.fixture(name="langchain_nvidia_ai_endpoints", scope='session', autouse=True) def langchain_nvidia_ai_endpoints_fixture(langchain_nvidia_ai_endpoints: types.ModuleType): """ diff --git a/tests/morpheus_llm/llm/test_agents_simple_pipe.py b/tests/morpheus_llm/llm/test_agents_simple_pipe.py index d219a9780..8aa9e0d0e 100644 --- a/tests/morpheus_llm/llm/test_agents_simple_pipe.py +++ b/tests/morpheus_llm/llm/test_agents_simple_pipe.py @@ -127,7 +127,7 @@ def test_agents_simple_pipe_integration_openai(config: Config, questions: list[s assert float(response_match.group(1)) >= 3.7 -@pytest.mark.usefixtures("openai", "restore_environ") +@pytest.mark.usefixtures("langchain_community", "langchain_openai", "openai", "restore_environ") @mock.patch("langchain_community.utilities.serpapi.SerpAPIWrapper.aresults") @mock.patch("langchain_openai.OpenAI._agenerate", autospec=True) # autospec is needed as langchain will inspect the function