签入版本
CI / lint (push) Canceled after 0s
CI / test (push) Canceled after 0s

This commit is contained in:
2026-09-16 10:08:07 +08:00
commit fda0fe1a53
820 changed files with 97186 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
"""集成测试配置:MySQL/Redis 不可用或认证失败时自动跳过。"""
import pytest
def _services_available() -> bool:
"""尝试真实连接 MySQL 与 Redis,任一不可用则跳过集成测试。"""
try:
# 数据库连通性 + 认证(select(1) 跨方言,Oracle 下自动渲染 SELECT 1 FROM DUAL)
from sqlalchemy import select
from extensions.sqlalchemy import engine
with engine.connect() as conn:
conn.execute(select(1))
# Redis 连通性
from core.redis import redis
redis.ping()
return True
except Exception:
return False
SERVICES_AVAILABLE = _services_available()
@pytest.fixture(autouse=True)
def _skip_without_services(request):
"""集成测试依赖 MySQL/Redis,服务不可用或认证失败时跳过。"""
if "integration" in request.keywords and not SERVICES_AVAILABLE:
pytest.skip("MySQL/Redis 服务不可用或认证失败,跳过集成测试")