Update: improve the unit testing of tutorial assistants and OCR assistants.

This commit is contained in:
Stitch-z 2023-12-26 15:38:24 +08:00
parent dc77a0d99b
commit 25b58f22ca

View file

@ -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"])