mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
加插件包导入冒烟测试,1 例
This commit is contained in:
parent
7ac454a1b9
commit
caab6a145d
2 changed files with 26 additions and 0 deletions
0
main/xiaozhi-server/tests/plugins_func/__init__.py
Normal file
0
main/xiaozhi-server/tests/plugins_func/__init__.py
Normal file
26
main/xiaozhi-server/tests/plugins_func/test_loadplugins.py
Normal file
26
main/xiaozhi-server/tests/plugins_func/test_loadplugins.py
Normal file
|
|
@ -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")
|
||||||
Loading…
Reference in a new issue