From 25b58f22ca092c89b076f66001f8c476479859a4 Mon Sep 17 00:00:00 2001 From: Stitch-z <284618289@qq.com> Date: Tue, 26 Dec 2023 15:38:24 +0800 Subject: [PATCH] Update: improve the unit testing of tutorial assistants and OCR assistants. --- tests/metagpt/roles/test_tutorial_assistant.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/metagpt/roles/test_tutorial_assistant.py b/tests/metagpt/roles/test_tutorial_assistant.py index f019c07d4..4455e1bf6 100644 --- a/tests/metagpt/roles/test_tutorial_assistant.py +++ b/tests/metagpt/roles/test_tutorial_assistant.py @@ -5,19 +5,27 @@ @Author : Stitch-z @File : test_tutorial_assistant.py """ +import shutil import aiofiles import pytest +from metagpt.const import TUTORIAL_PATH from metagpt.roles.tutorial_assistant import TutorialAssistant @pytest.mark.asyncio @pytest.mark.parametrize(("language", "topic"), [("Chinese", "Write a tutorial about pip")]) async def test_tutorial_assistant(language: str, topic: str): + shutil.rmtree(path=TUTORIAL_PATH, ignore_errors=True) + role = TutorialAssistant(language=language) msg = await role.run(topic) + assert TUTORIAL_PATH.exists() filename = msg.content async with aiofiles.open(filename, mode="r", encoding="utf-8") as reader: content = await reader.read() - assert content + assert "pip" in content + +if __name__ == "__main__": + pytest.main([__file__, "-s"])