Skip to content

Commit c2e59b4

Browse files
committed
Skip ragas tests if ragas not available
1 parent e0da7f9 commit c2e59b4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/llmobs/conftest.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,20 @@ def mock_ragas_dependencies_not_present():
198198
@pytest.fixture
199199
def ragas(mock_llmobs_span_writer, mock_llmobs_eval_metric_writer):
200200
with override_global_config(dict(_dd_api_key="<not-a-real-key>")):
201-
import ragas
202-
201+
try:
202+
import ragas
203+
except ImportError:
204+
pytest.skip("Ragas not installed")
203205
with override_env(dict(OPENAI_API_KEY=os.getenv("OPENAI_API_KEY", "<not-a-real-key>"))):
204206
yield ragas
205207

206208

207209
@pytest.fixture
208210
def reset_ragas_faithfulness_llm():
209-
import ragas
210-
211+
try:
212+
import ragas
213+
except ImportError:
214+
pytest.skip("Ragas not installed")
211215
previous_llm = ragas.metrics.faithfulness.llm
212216
yield
213217
ragas.metrics.faithfulness.llm = previous_llm

0 commit comments

Comments
 (0)