From 97f156b10d5fdb54dedc8076069d59bfae5713a7 Mon Sep 17 00:00:00 2001 From: seehi <6580@pm.me> Date: Thu, 7 Dec 2023 10:23:08 +0800 Subject: [PATCH] revert pytest.MonkeyPatch --- tests/metagpt/provider/test_zhipuai_api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/metagpt/provider/test_zhipuai_api.py b/tests/metagpt/provider/test_zhipuai_api.py index 08c95a337..4684e8887 100644 --- a/tests/metagpt/provider/test_zhipuai_api.py +++ b/tests/metagpt/provider/test_zhipuai_api.py @@ -15,8 +15,8 @@ def mock_llm_ask(self, messages: list[dict]) -> dict: return default_resp -def test_zhipuai_completion(monkeypatch: pytest.MonkeyPatch): - monkeypatch.setattr(ZhiPuAIGPTAPI, "completion", mock_llm_ask) +def test_zhipuai_completion(mocker): + mocker.patch("metagpt.provider.zhipuai_api.ZhiPuAIGPTAPI.completion", mock_llm_ask) resp = ZhiPuAIGPTAPI().completion(messages) assert resp["code"] == 200 @@ -28,8 +28,8 @@ async def mock_llm_aask(self, messgaes: list[dict], stream: bool = False) -> dic @pytest.mark.asyncio -async def test_zhipuai_acompletion(monkeypatch: pytest.MonkeyPatch): - monkeypatch.setattr(ZhiPuAIGPTAPI, "acompletion_text", mock_llm_aask) +async def test_zhipuai_acompletion(mocker): + mocker.patch("metagpt.provider.zhipuai_api.ZhiPuAIGPTAPI.acompletion_text", mock_llm_aask) resp = await ZhiPuAIGPTAPI().acompletion_text(messages, stream=False)