Files
AI/참고/instructor-main/tests/llm/test_genai/conftest.py

41 lines
922 B
Python
Raw Normal View History

2026-05-12 19:40:31 +09:00
# conftest.py
import os
import pytest
import instructor
if not os.getenv("GOOGLE_API_KEY"):
pytest.skip(
"GOOGLE_API_KEY environment variable not set",
allow_module_level=True,
)
if not os.getenv("GOOGLE_GENAI_MODEL"):
pytest.skip(
"GOOGLE_GENAI_MODEL environment variable not set",
allow_module_level=True,
)
try:
from google.genai import Client
except ImportError: # pragma: no cover - optional dependency
pytest.skip("google-genai package is not installed", allow_module_level=True)
@pytest.fixture(scope="function")
def client():
yield Client()
@pytest.fixture(scope="function")
def aclient():
yield Client()
@pytest.fixture(scope="function")
def genai_client():
# Use the recommended model for sync client, let the test set the mode
return instructor.from_provider(
os.getenv("GOOGLE_GENAI_MODEL", "google/gemini-pro"),
)