ForcePilot/backend/test/conftest.py
Kris 3264900bc9 test: 新增多渠道单元测试用例并配置测试环境变量
新增了Twitch、Telegram、Discord、Slack、Mattermost、WeChat、Zalo等多渠道的单元测试用例,覆盖了令牌处理、速率限制、消息去重、会话解析、格式转换、安全策略等模块
同时在测试配置中添加了测试用的OpenAI API密钥环境变量
2026-05-12 00:56:47 +08:00

30 lines
1.1 KiB
Python

from __future__ import annotations
import os
import sys
from pathlib import Path
import pytest
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
# Avoid package-level knowledge graph initialization during pytest collection.
os.environ.setdefault("YUXI_SKIP_APP_INIT", "1")
# Provide dummy model provider for unit tests
os.environ.setdefault("OPENAI_API_KEY", "test_key_for_unit_tests")
def pytest_configure(config: pytest.Config) -> None:
"""Register shared markers without binding every test to a live environment."""
config.addinivalue_line("markers", "unit: marks tests that run without live services")
config.addinivalue_line("markers", "auth: marks tests that require authentication")
config.addinivalue_line("markers", "integration: marks tests that hit the live API service")
config.addinivalue_line("markers", "e2e: marks tests that exercise an end-to-end workflow")
config.addinivalue_line("markers", "slow: marks tests as slow")
pytest_plugins = ["pytest_asyncio"]