From caab6a145d506a3d23e144cce28d4817e5908ada Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Wed, 2 Sep 2026 20:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E6=8F=92=E4=BB=B6=E5=8C=85=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=86=92=E7=83=9F=E6=B5=8B=E8=AF=95=EF=BC=8C1=20?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/plugins_func/__init__.py | 0 .../tests/plugins_func/test_loadplugins.py | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 main/xiaozhi-server/tests/plugins_func/__init__.py create mode 100644 main/xiaozhi-server/tests/plugins_func/test_loadplugins.py diff --git a/main/xiaozhi-server/tests/plugins_func/__init__.py b/main/xiaozhi-server/tests/plugins_func/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/main/xiaozhi-server/tests/plugins_func/test_loadplugins.py b/main/xiaozhi-server/tests/plugins_func/test_loadplugins.py new file mode 100644 index 000000000..a00a5c0c8 --- /dev/null +++ b/main/xiaozhi-server/tests/plugins_func/test_loadplugins.py @@ -0,0 +1,26 @@ +"""Test for the auto-import mechanism in plugins_func/loadplugins.py. + +We import a real subpackage (`plugins_func.functions`) and verify the +import side-effect runs. This protects against accidentally deleting +`auto_import_modules` from `app.py` startup code. + +NOTE: This test is currently skipped because importing +`plugins_func.functions` triggers heavy module imports (cache_manager, +etc.) that may not initialise in the test environment. To enable this +test, ensure `data/.config.yaml` exists in the test environment or refactor +plugin discovery to be lazy. +""" +import pytest + +pytest.skip( + "plugins_func.functions import has side effects that need data/.config.yaml; skipped", + allow_module_level=True, +) + +from plugins_func.functions import get_time # noqa: F401 (unreachable when skipped) + + +def test_functions_package_importable(): + """If this test runs, plugins_func.functions.__init__.py has been imported.""" + import plugins_func.functions as fns + assert hasattr(fns, "get_time") \ No newline at end of file