chore: fix test (#3787)
This commit is contained in:
@@ -14,7 +14,7 @@ from astrbot.core.utils.session_waiter import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Waiter(Star):
|
class Main(Star):
|
||||||
"""会话控制"""
|
"""会话控制"""
|
||||||
|
|
||||||
def __init__(self, context: Context):
|
def __init__(self, context: Context):
|
||||||
|
|||||||
@@ -21,7 +21,17 @@ async def core_lifecycle_td(tmp_path_factory):
|
|||||||
log_broker = LogBroker()
|
log_broker = LogBroker()
|
||||||
core_lifecycle = AstrBotCoreLifecycle(log_broker, db)
|
core_lifecycle = AstrBotCoreLifecycle(log_broker, db)
|
||||||
await core_lifecycle.initialize()
|
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")
|
@pytest.fixture(scope="module")
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ def plugin_manager_pm(tmp_path):
|
|||||||
message_history_manager = MagicMock()
|
message_history_manager = MagicMock()
|
||||||
persona_manager = MagicMock()
|
persona_manager = MagicMock()
|
||||||
astrbot_config_mgr = MagicMock()
|
astrbot_config_mgr = MagicMock()
|
||||||
|
knowledge_base_manager = MagicMock()
|
||||||
|
|
||||||
star_context = Context(
|
star_context = Context(
|
||||||
event_queue,
|
event_queue,
|
||||||
@@ -50,6 +51,7 @@ def plugin_manager_pm(tmp_path):
|
|||||||
message_history_manager,
|
message_history_manager,
|
||||||
persona_manager,
|
persona_manager,
|
||||||
astrbot_config_mgr,
|
astrbot_config_mgr,
|
||||||
|
knowledge_base_manager=knowledge_base_manager,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create the PluginManager instance
|
# Create the PluginManager instance
|
||||||
|
|||||||
Reference in New Issue
Block a user