ruoxi_sun 58657935fc bundle fingerprint tool repos into evalstone for self-containment
Vendor LLMmap / llm-verify / llm-fingerprint-detector under
bash/fingerprint/tools so the three fingerprint benchmarks run with only
/data1/eval mounted (no /data1/xii dependency):
- run.py DEFAULT_TOOLS_ROOT prefers builtin tools/, falls back to /data1/xii
- exclude .git / node_modules / template backups
- detector dist/ (pre-built) retained; node_modules not needed at runtime
2026-09-03 06:45:46 +00:00

67 lines
1.9 KiB
Python

"""Shared test fixtures for the AI Benchmarker test suite."""
import asyncio
from collections.abc import AsyncGenerator
import pytest
import pytest_asyncio
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from src.database import Base
@pytest.fixture(scope="session")
def event_loop():
"""Create a single event loop for the entire test session."""
loop = asyncio.new_event_loop()
yield loop
loop.close()
@pytest_asyncio.fixture
async def db_session() -> AsyncGenerator[AsyncSession, None]:
"""Create an in-memory SQLite database session for testing.
Each test gets a fresh database with all tables created.
The session is rolled back after each test for isolation.
"""
engine = create_async_engine("sqlite+aiosqlite:///:memory:", echo=False)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
session_factory = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
async with session_factory() as session:
yield session
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await engine.dispose()
@pytest.fixture
def sample_model_configs() -> list[dict]:
"""Sample model configurations for testing."""
return [
{
"model_name": "gpt-4o",
"provider": "openai",
"api_key": "test-key-openai",
"api_base_url": "",
},
{
"model_name": "claude-sonnet-4-20250514",
"provider": "anthropic",
"api_key": "test-key-anthropic",
"api_base_url": "",
},
{
"model_name": "suspect-model",
"provider": "suspect",
"api_key": "test-key-suspect",
"api_base_url": "https://api.suspect.example.com/v1",
},
]