@@ -117,7 +117,7 @@ def dummy_avatar(base_world):
|
||||
|
||||
return av
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_llm_managers():
|
||||
"""
|
||||
Mock 所有涉及 LLM 调用的管理器和函数,防止测试中意外调用 LLM。
|
||||
@@ -134,6 +134,7 @@ def mock_llm_managers():
|
||||
patch("src.classes.relation_resolver.RelationResolver.run_batch", new_callable=AsyncMock) as mock_rr, \
|
||||
patch("src.classes.history.HistoryManager.apply_history_influence", new_callable=AsyncMock) as mock_hist, \
|
||||
patch("src.classes.story_teller.StoryTeller.tell_story", new_callable=AsyncMock) as mock_story, \
|
||||
patch("src.classes.story_teller.StoryTeller.tell_gathering_story", new_callable=AsyncMock) as mock_gathering_story, \
|
||||
patch("src.utils.llm.config.LLMConfig.from_mode", return_value=mock_llm_config) as mock_config:
|
||||
|
||||
mock_ai.decide = AsyncMock(return_value={})
|
||||
@@ -142,6 +143,7 @@ def mock_llm_managers():
|
||||
mock_rr.return_value = []
|
||||
mock_hist.return_value = None
|
||||
mock_story.return_value = "测试故事"
|
||||
mock_gathering_story.return_value = "秘境测试故事"
|
||||
|
||||
yield {
|
||||
"ai": mock_ai,
|
||||
@@ -150,6 +152,7 @@ def mock_llm_managers():
|
||||
"rr": mock_rr,
|
||||
"hist": mock_hist,
|
||||
"story": mock_story,
|
||||
"gathering_story": mock_gathering_story,
|
||||
"config": mock_config
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user