mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-26 04:39:53 +01:00
配 pytest 与 conftest,修模块路径
This commit is contained in:
parent
b90dd01826
commit
a0dd138e93
2 changed files with 21 additions and 0 deletions
10
main/xiaozhi-server/pyproject.toml
Normal file
10
main/xiaozhi-server/pyproject.toml
Normal 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",
|
||||||
|
]
|
||||||
11
main/xiaozhi-server/tests/conftest.py
Normal file
11
main/xiaozhi-server/tests/conftest.py
Normal 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))
|
||||||
Loading…
Reference in a new issue