| 1234567891011121314151617181920212223242526 |
- """全局测试 fixtures。"""
- import pytest
- @pytest.fixture(scope="session")
- def config_handler():
- """会话级:配置读取器。"""
- from foundation.infrastructure.config.config import config_handler
- return config_handler
- @pytest.fixture(scope="session")
- def model_handler():
- """会话级:模型客户端管理器。"""
- from foundation.ai.models.model_handler import model_handler
- return model_handler
- @pytest.fixture
- async def redis_client():
- """函数级:Redis 连接(测试后自动清理)。"""
- from foundation.infrastructure.cache import RedisConnectionFactory
- client = RedisConnectionFactory.get()
- yield client
- for key in client.keys("test:*"):
- client.delete(key)
|