diff --git a/main/xiaozhi-server/pyproject.toml b/main/xiaozhi-server/pyproject.toml new file mode 100644 index 000000000..6f0998775 --- /dev/null +++ b/main/xiaozhi-server/pyproject.toml @@ -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", +] \ No newline at end of file diff --git a/main/xiaozhi-server/tests/conftest.py b/main/xiaozhi-server/tests/conftest.py new file mode 100644 index 000000000..b2c68f92a --- /dev/null +++ b/main/xiaozhi-server/tests/conftest.py @@ -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)) \ No newline at end of file