Skip to content

Commit 9d5e6a3

Browse files
committed
Update test to skip when optional dependencies are not installed
1 parent b35d861 commit 9d5e6a3

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,16 @@ def langchain_community_fixture(fail_missing: bool):
11251125
fail_missing=fail_missing)
11261126

11271127

1128+
@pytest.fixture(name="langchain_openai", scope='session')
1129+
def langchain_community_fixture(fail_missing: bool):
1130+
"""
1131+
Fixture to ensure langchain_openai is installed
1132+
"""
1133+
yield import_or_skip("langchain_openai",
1134+
reason=OPT_DEP_SKIP_REASON.format(package="langchain_openai"),
1135+
fail_missing=fail_missing)
1136+
1137+
11281138
@pytest.fixture(name="langchain_nvidia_ai_endpoints", scope='session')
11291139
def langchain_nvidia_ai_endpoints_fixture(fail_missing: bool):
11301140
"""

tests/morpheus_llm/llm/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def langchain_community_fixture(langchain_community: types.ModuleType):
6161
yield langchain_community
6262

6363

64+
@pytest.fixture(name="langchain_openai", scope='session', autouse=True)
65+
def langchain_community_fixture(langchain_openai: types.ModuleType):
66+
"""
67+
Fixture to ensure langchain_openai is installed
68+
"""
69+
yield langchain_openai
70+
71+
6472
@pytest.fixture(name="langchain_nvidia_ai_endpoints", scope='session', autouse=True)
6573
def langchain_nvidia_ai_endpoints_fixture(langchain_nvidia_ai_endpoints: types.ModuleType):
6674
"""

tests/morpheus_llm/llm/test_agents_simple_pipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def test_agents_simple_pipe_integration_openai(config: Config, questions: list[s
127127
assert float(response_match.group(1)) >= 3.7
128128

129129

130-
@pytest.mark.usefixtures("openai", "restore_environ")
130+
@pytest.mark.usefixtures("langchain_community", "langchain_openai", "openai", "restore_environ")
131131
@mock.patch("langchain_community.utilities.serpapi.SerpAPIWrapper.aresults")
132132
@mock.patch("langchain_openai.OpenAI._agenerate",
133133
autospec=True) # autospec is needed as langchain will inspect the function

0 commit comments

Comments
 (0)