chore: fix test (#3787)

This commit is contained in:
Dt8333
2025-11-27 14:02:42 +08:00
committed by GitHub
parent 3e7bb80492
commit 758ce40cc1
3 changed files with 14 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ from astrbot.core.utils.session_waiter import (
)
class Waiter(Star):
class Main(Star):
"""会话控制"""
def __init__(self, context: Context):

View File

@@ -21,7 +21,17 @@ async def core_lifecycle_td(tmp_path_factory):
log_broker = LogBroker()
core_lifecycle = AstrBotCoreLifecycle(log_broker, db)
await core_lifecycle.initialize()
return core_lifecycle
try:
yield core_lifecycle
finally:
# 优先停止核心生命周期以释放资源(包括关闭 MCP 等后台任务)
try:
_stop_res = core_lifecycle.stop()
if asyncio.iscoroutine(_stop_res):
await _stop_res
except Exception:
# 停止过程中如有异常,不影响后续清理
pass
@pytest.fixture(scope="module")

View File

@@ -39,6 +39,7 @@ def plugin_manager_pm(tmp_path):
message_history_manager = MagicMock()
persona_manager = MagicMock()
astrbot_config_mgr = MagicMock()
knowledge_base_manager = MagicMock()
star_context = Context(
event_queue,
@@ -50,6 +51,7 @@ def plugin_manager_pm(tmp_path):
message_history_manager,
persona_manager,
astrbot_config_mgr,
knowledge_base_manager=knowledge_base_manager,
)
# Create the PluginManager instance