配 pytest 与 conftest,修模块路径

This commit is contained in:
hrz 2026-09-02 19:57:31 +08:00
parent b90dd01826
commit a0dd138e93
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,10 @@
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = "-ra"
filterwarnings = [
"ignore::DeprecationWarning",
]

View file

@ -0,0 +1,11 @@
"""Pytest configuration — must run BEFORE any test imports project modules.
Adds the xiaozhi-server directory to sys.path so the existing implicit
relative imports (`from core.utils.textUtils import ...`) resolve.
"""
import sys
from pathlib import Path
_PROJECT_ROOT = Path(__file__).resolve().parent.parent
if str(_PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(_PROJECT_ROOT))